Changeset 88
- Timestamp:
- 11/29/06 16:05:09 (6 years ago)
- Files:
-
- trunk/SYMFONY (modified) (1 diff)
- trunk/apps/frontend/config/cache.yml (modified) (1 diff)
- trunk/apps/frontend/config/config.php (modified) (1 diff)
- trunk/apps/frontend/config/filters.yml (modified) (1 diff)
- trunk/apps/frontend/config/logging.yml (modified) (1 diff)
- trunk/apps/frontend/config/view.yml (modified) (1 diff)
- trunk/apps/frontend/lib/helper/UserHelper.php (modified) (1 diff)
- trunk/apps/frontend/modules/answer/templates/_answer.php (modified) (1 diff)
- trunk/apps/frontend/modules/answer/templates/recentSuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/moderator/templates/reportedAnswersSuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/moderator/templates/reportedQuestionsSuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/question/templates/_question_block.php (modified) (1 diff)
- trunk/apps/frontend/modules/question/templates/_question_list.php (modified) (1 diff)
- trunk/apps/frontend/modules/question/templates/addSuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/question/templates/searchSuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/question/templates/showSuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/tag/config/cache.yml (modified) (1 diff)
- trunk/apps/frontend/modules/user/templates/listInterestedBySuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/user/templates/loginSuccess.php (modified) (1 diff)
- trunk/apps/frontend/modules/user/templates/showSuccess.php (modified) (1 diff)
- trunk/apps/frontend/templates/layout.php (modified) (1 diff)
- trunk/config/config.php (modified) (1 diff)
- trunk/config/propel.ini (modified) (4 diffs)
- trunk/config/schema.xml (modified) (1 diff)
- trunk/data/sql/lib.model.schema.sql (added)
- trunk/data/sql/sqldb.map (modified) (1 diff)
- trunk/lib/model/Answer.php (modified) (1 diff)
- trunk/lib/model/AnswerPeer.php (modified) (1 diff)
- trunk/lib/model/Interest.php (modified) (1 diff)
- trunk/lib/model/InterestPeer.php (modified) (1 diff)
- trunk/lib/model/Question.php (modified) (1 diff)
- trunk/lib/model/QuestionPeer.php (modified) (2 diffs)
- trunk/lib/model/QuestionTag.php (modified) (1 diff)
- trunk/lib/model/QuestionTagPeer.php (modified) (1 diff)
- trunk/lib/model/Relevancy.php (modified) (1 diff)
- trunk/lib/model/RelevancyPeer.php (modified) (1 diff)
- trunk/lib/model/ReportAnswer.php (modified) (1 diff)
- trunk/lib/model/ReportAnswerPeer.php (modified) (1 diff)
- trunk/lib/model/ReportQuestion.php (modified) (1 diff)
- trunk/lib/model/ReportQuestionPeer.php (modified) (1 diff)
- trunk/lib/model/SearchIndex.php (modified) (1 diff)
- trunk/lib/model/SearchIndexPeer.php (modified) (1 diff)
- trunk/lib/model/User.php (modified) (1 diff)
- trunk/lib/model/UserPeer.php (modified) (1 diff)
- trunk/lib/model/map/AnswerMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/map/InterestMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/map/QuestionMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/map/QuestionTagMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/map/RelevancyMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/map/ReportAnswerMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/map/ReportQuestionMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/map/SearchIndexMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/map/UserMapBuilder.php (modified) (4 diffs)
- trunk/lib/model/om/BaseAnswer.php (modified) (61 diffs)
- trunk/lib/model/om/BaseAnswerPeer.php (modified) (49 diffs)
- trunk/lib/model/om/BaseInterest.php (modified) (34 diffs)
- trunk/lib/model/om/BaseInterestPeer.php (modified) (50 diffs)
- trunk/lib/model/om/BaseQuestion.php (modified) (83 diffs)
- trunk/lib/model/om/BaseQuestionPeer.php (modified) (35 diffs)
- trunk/lib/model/om/BaseQuestionTag.php (modified) (38 diffs)
- trunk/lib/model/om/BaseQuestionTagPeer.php (modified) (50 diffs)
- trunk/lib/model/om/BaseRelevancy.php (modified) (36 diffs)
- trunk/lib/model/om/BaseRelevancyPeer.php (modified) (50 diffs)
- trunk/lib/model/om/BaseReportAnswer.php (modified) (34 diffs)
- trunk/lib/model/om/BaseReportAnswerPeer.php (modified) (50 diffs)
- trunk/lib/model/om/BaseReportQuestion.php (modified) (34 diffs)
- trunk/lib/model/om/BaseReportQuestionPeer.php (modified) (50 diffs)
- trunk/lib/model/om/BaseSearchIndex.php (modified) (30 diffs)
- trunk/lib/model/om/BaseSearchIndexPeer.php (modified) (34 diffs)
- trunk/lib/model/om/BaseUser.php (modified) (98 diffs)
- trunk/lib/model/om/BaseUserPeer.php (modified) (26 diffs)
- trunk/plugins (added)
- trunk/plugins/.channels (added)
- trunk/plugins/.channels/.alias (added)
- trunk/plugins/.channels/.alias/pear.txt (added)
- trunk/plugins/.channels/.alias/pecl.txt (added)
- trunk/plugins/.channels/.alias/symfony.txt (added)
- trunk/plugins/.channels/__uri.reg (added)
- trunk/plugins/.channels/pear.php.net.reg (added)
- trunk/plugins/.channels/pear.symfony-project.com.reg (added)
- trunk/plugins/.channels/pecl.php.net.reg (added)
- trunk/plugins/.depdb (added)
- trunk/plugins/.depdblock (added)
- trunk/plugins/.filemap (added)
- trunk/plugins/.lock (added)
- trunk/plugins/.pearrc (added)
- trunk/plugins/.registry (added)
- trunk/plugins/.registry/.channel.__uri (added)
- trunk/plugins/.registry/.channel.pear.symfony-project.com (added)
- trunk/plugins/.registry/.channel.pear.symfony-project.com/sffeedplugin.reg (added)
- trunk/plugins/.registry/.channel.pear.symfony-project.com/symfony.reg (added)
- trunk/plugins/.registry/.channel.pecl.php.net (added)
- trunk/plugins/sfFeedPlugin (added)
- trunk/plugins/sfFeedPlugin/LICENSE (added)
- trunk/plugins/sfFeedPlugin/README (added)
- trunk/plugins/sfFeedPlugin/lib (added)
- trunk/plugins/sfFeedPlugin/lib/sfAtom1Feed.class.php (added)
- trunk/plugins/sfFeedPlugin/lib/sfFeed.class.php (added)
- trunk/plugins/sfFeedPlugin/lib/sfFeedEnclosure.class.php (added)
- trunk/plugins/sfFeedPlugin/lib/sfFeedItem.class.php (added)
- trunk/plugins/sfFeedPlugin/lib/sfRss201rev2Feed.class.php (added)
- trunk/plugins/sfFeedPlugin/lib/sfRssFeed.class.php (added)
- trunk/plugins/sfFeedPlugin/lib/sfRssUserland091Feed.class.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SYMFONY
r2 r88 1 #!/usr/bin/env php 2 <?php 3 4 /* 5 * This file is part of the symfony package. 6 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 chdir(dirname(__FILE__)); 13 include('config/config.php'); 14 include($sf_symfony_data_dir.'/bin/symfony.php'); trunk/apps/frontend/config/cache.yml
r2 r88 1 1 default: 2 activate:off3 type: slot2 enabled: off 3 with_layout: false 4 4 lifetime: 86400 trunk/apps/frontend/config/config.php
r71 r88 1 1 <?php 2 2 3 // symfony directories 4 if (is_readable(SF_ROOT_DIR.'/lib/symfony/symfony.php')) 5 { 6 // symlink exists 7 $sf_symfony_lib_dir = SF_ROOT_DIR.'/lib/symfony'; 8 $sf_symfony_data_dir = SF_ROOT_DIR.'/data/symfony'; 9 $sf_version = '@DEV@'; 10 } 11 else 12 { 13 // PEAR config 14 if ((include('symfony/pear.php')) != 'OK') 15 { 16 throw new Exception('Unable to find symfony librairies'); 17 } 18 } 3 // include project configuration 4 include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 19 5 20 require_once($sf_symfony_lib_dir.'/config/sfConfig.class.php'); 21 22 sfConfig::add(array( 23 'sf_root_dir' => SF_ROOT_DIR, 24 'sf_app' => SF_APP, 25 'sf_environment' => SF_ENVIRONMENT, 26 'sf_debug' => SF_DEBUG, 27 'sf_symfony_lib_dir' => $sf_symfony_lib_dir, 28 'sf_symfony_data_dir' => $sf_symfony_data_dir, 29 'sf_test' => false, 30 'sf_version' => $sf_version, 31 )); 32 33 // start timer 34 if (sfConfig::get('sf_debug')) 35 { 36 sfConfig::set('sf_timer_start', microtime(true)); 37 } 38 39 // directory layout 40 include($sf_symfony_data_dir.'/config/constants.php'); 41 42 // include path 43 set_include_path( 44 sfConfig::get('sf_lib_dir').PATH_SEPARATOR. 45 sfConfig::get('sf_app_lib_dir').PATH_SEPARATOR. 46 sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'vendor'.PATH_SEPARATOR. 47 get_include_path() 48 ); 49 50 // check to see if we're not in a cache cleaning process 51 require_once(sfConfig::get('sf_symfony_lib_dir').'/util/sfToolkit.class.php'); 52 if (sfToolkit::hasLockFile(SF_ROOT_DIR.DIRECTORY_SEPARATOR.SF_APP.'_'.SF_ENVIRONMENT.'.lck', 5)) 53 { 54 // application is not yet available 55 include(SF_WEB_DIR.'/unavailable.html'); 56 die(1); 57 } 58 59 // require project configuration 60 require_once(sfConfig::get('sf_config_dir').'/config.php'); 61 62 // recent symfony update? 63 $version = @file_get_contents(sfConfig::get('sf_config_cache_dir').'/VERSION'); 64 if ($version != $sf_version) 65 { 66 // force cache regeneration 67 foreach (array(sfConfig::get('sf_config_cache_dir').'/config_bootstrap_compile.yml.php', sfConfig::get('sf_config_cache_dir').'/config_core_compile.yml.php') as $file) 68 { 69 if (is_readable($file)) 70 { 71 unlink($file); 72 } 73 } 74 } 75 76 // go 77 $bootstrap = sfConfig::get('sf_config_cache_dir').'/config_bootstrap_compile.yml.php'; 78 if (is_readable($bootstrap)) 79 { 80 require_once($bootstrap); 81 } 82 else 83 { 84 require_once(sfConfig::get('sf_symfony_lib_dir').'/symfony.php'); 85 } 86 87 ?> 6 // symfony bootstraping 7 require_once($sf_symfony_lib_dir.'/util/sfCore.class.php'); 8 sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir); trunk/apps/frontend/config/filters.yml
r49 r88 1 rendering: ~ 2 web_debug: ~ 3 security: ~ 4 5 # generally, you will want to insert your own filters here 1 6 myTagFilter: 2 7 class: myTagFilter 3 8 param: 4 9 host_exclude_regex: /^(www|askeet)/ 10 11 12 cache: ~ 13 common: ~ 14 flash: ~ 15 execution: ~ trunk/apps/frontend/config/logging.yml
r71 r88 7 7 8 8 all: 9 # active: on9 # enabled: on 10 10 # level: debug trunk/apps/frontend/config/view.yml
r76 r88 12 12 stylesheets: [main, layout] 13 13 14 javascripts: [ /sf/js/prototype/prototype.js]14 javascripts: [%SF_PROTOTYPE_WEB_DIR%/js/prototype.js] 15 15 16 16 has_layout: on trunk/apps/frontend/lib/helper/UserHelper.php
r64 r88 1 1 <?php 2 2 3 use_helper s('Javascript', 'Global');3 use_helper('Javascript', 'Global'); 4 4 5 5 function link_to_user_interested($user, $question) trunk/apps/frontend/modules/answer/templates/_answer.php
r69 r88 1 <?php use_helper s('Date', 'User') ?>1 <?php use_helper('Date', 'User') ?> 2 2 3 3 <div class="vote_block" id="vote_<?php echo $answer->getId() ?>"> trunk/apps/frontend/modules/answer/templates/recentSuccess.php
r80 r88 1 <?php use_helper s('Date', 'Answer', 'Question') ?>1 <?php use_helper('Date', 'Answer', 'Question') ?> 2 2 3 3 <h1><?php echo __('recent answers') ?></h1> trunk/apps/frontend/modules/moderator/templates/reportedAnswersSuccess.php
r74 r88 1 <?php use_helper s('Date', 'User', 'Global', 'Question') ?>1 <?php use_helper('Date', 'User', 'Global', 'Question') ?> 2 2 3 3 <h1><?php echo __('answers reported as spam') ?></h1> trunk/apps/frontend/modules/moderator/templates/reportedQuestionsSuccess.php
r74 r88 1 <?php use_helper s('Text', 'Global', 'Question', 'Date', 'User') ?>1 <?php use_helper('Text', 'Global', 'Question', 'Date', 'User') ?> 2 2 3 3 <h1><?php echo __('questions reported as spam') ?></h1> trunk/apps/frontend/modules/question/templates/_question_block.php
r69 r88 1 <?php use_helper s('Text', 'Global', 'Question', 'Date') ?>1 <?php use_helper('Text', 'Global', 'Question', 'Date') ?> 2 2 3 3 <div class="question"> trunk/apps/frontend/modules/question/templates/_question_list.php
r79 r88 1 <?php use_helper s('Global') ?>1 <?php use_helper('Global') ?> 2 2 3 3 <?php foreach($question_pager->getResults() as $question): ?> trunk/apps/frontend/modules/question/templates/addSuccess.php
r69 r88 1 <?php use_helper('Javascript' ) ?>1 <?php use_helper('Javascript', 'Validation') ?> 2 2 3 3 <h1><?php echo __('ask a question') ?></h1> trunk/apps/frontend/modules/question/templates/searchSuccess.php
r69 r88 1 <?php use_helper s('Global') ?>1 <?php use_helper('Global') ?> 2 2 3 3 <h1><?php echo __('questions matching "%1%"', array('%1%' => htmlspecialchars($sf_params->get('search')))) ?></h1> trunk/apps/frontend/modules/question/templates/showSuccess.php
r69 r88 1 <?php use_helper s('Date', 'Answer', 'Question') ?>1 <?php use_helper('Date', 'Answer', 'Question') ?> 2 2 3 3 <h1></h1> trunk/apps/frontend/modules/tag/config/cache.yml
r53 r88 1 1 popular: 2 activate:on3 type: slot2 enabled: on 3 with_layout: false 4 4 5 5 all: trunk/apps/frontend/modules/user/templates/listInterestedBySuccess.php
r69 r88 1 <?php use_helper s('Date', 'Global') ?>1 <?php use_helper('Date', 'Global') ?> 2 2 3 3 <h2><?php echo $question->getTitle() ?></h2> trunk/apps/frontend/modules/user/templates/loginSuccess.php
r76 r88 1 <?php use_helper s('Validation', 'Javascript') ?>1 <?php use_helper('Validation', 'Javascript') ?> 2 2 3 3 <h1><?php echo __('sign in / register') ?></h1> trunk/apps/frontend/modules/user/templates/showSuccess.php
r69 r88 1 <?php use_helper s('Date', 'Question', 'Text', 'Object') ?>1 <?php use_helper('Date', 'Question', 'Text', 'Object', 'Validation') ?> 2 2 3 3 <h1><?php echo __('%1%\'s profile', array('%1%' => $subscriber->__toString())) ?> trunk/apps/frontend/templates/layout.php
r72 r88 8 8 <?php echo include_title() ?> 9 9 10 <?php echo include_stylesheets() ?> 11 <?php echo include_javascripts() ?> 10 11 12 12 13 13 <?php echo auto_discovery_link_tag('rss', 'feed/popular') ?> trunk/config/config.php
r2 r88 1 1 <?php 2 2 3 $sf_symfony_lib_dir = dirname(__FILE__).'/../lib/vendor/symfony/lib'; 4 $sf_symfony_data_dir = dirname(__FILE__).'/../lib/vendor/symfony/data'; 5 6 3 7 ?> trunk/config/propel.ini
r71 r88 1 propel.targetPackage = model1 propel.targetPackage = lib.model 2 2 propel.project = askeet 3 3 propel.database = mysql 4 4 propel.database.createUrl = mysql://localhost/ 5 propel.database.url = mysql:// localhost/askeet5 propel.database.url = mysql://root@localhost/askeet 6 6 7 7 propel.mysql.tableType = InnoDB 8 8 propel.schema.validate = false 9 9 propel.addGenericAccessors = true 10 10 propel.addGenericMutators = true … … 19 19 propel.sql.dir = ${propel.output.dir}/data/sql 20 20 propel.runtime.conf.file = runtime-conf.xml 21 propel.php.dir = ${propel.output.dir} /lib21 propel.php.dir = ${propel.output.dir} 22 22 propel.default.schema.basename = schema 23 23 propel.datadump.mapper.from = *schema.xml … … 25 25 26 26 ; builder settings 27 propel.builder.peer.class = symfony.addon.propel.builder.SfPeerBuilder28 propel.builder.object.class = symfony.addon.propel.builder.SfObjectBuilder27 propel.builder.peer.class = addon.propel.builder.SfPeerBuilder 28 propel.builder.object.class = addon.propel.builder.SfObjectBuilder 29 29 30 propel.builder.objectstub.class = propel.engine.builder.om.php5.PHP5ExtensionObjectBuilder31 propel.builder.peerstub.class = propel.engine.builder.om.php5.PHP5ExtensionPeerBuilder32 propel.builder.objectmultiextend.class = propel.engine.builder.om.php5.PHP5MultiExtendObjectBuilder33 propel.builder.mapbuilder.class = propel.engine.builder.om.php5.PHP5MapBuilderBuilder30 propel.builder.objectstub.class = addon.propel.builder.SfExtensionObjectBuilder 31 propel.builder.peerstub.class = addon.propel.builder.SfExtensionPeerBuilder 32 propel.builder.objectmultiextend.class = addon.propel.builder.SfMultiExtendObjectBuilder 33 propel.builder.mapbuilder.class = addon.propel.builder.SfMapBuilderBuilder 34 34 propel.builder.interface.class = propel.engine.builder.om.php5.PHP5InterfaceBuilder 35 35 propel.builder.node.class = propel.engine.builder.om.php5.PHP5NodeBuilder … … 37 37 propel.builder.nodestub.class = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder 38 38 propel.builder.nodepeerstub.class = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder 39 propel.packageObjectModel = true 40 41 propel.builder.addIncludes = false 42 propel.builder.addComments = false trunk/config/schema.xml
r62 r88 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <database name="symfony" defaultIdMethod="native">2 <database package="lib.model" name="symfony" defaultIdMethod="native"> 3 3 <table name="ask_question" phpName="Question"> 4 4 <column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" /> trunk/data/sql/sqldb.map
r4 r88 1 1 # Sqlfile -> Database map 2 2 schema.sql=symfony 3 lib.model.schema.sql=symfony trunk/lib/model/Answer.php
r85 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseAnswer.php';3 require_once 'lib/model/om/BaseAnswer.php'; 4 4 5 5 trunk/lib/model/AnswerPeer.php
r69 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseAnswerPeer.php';4 require_once 'lib/model/om/BaseAnswerPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/Answer.php';7 include_once 'lib/model/Answer.php'; 8 8 9 9 trunk/lib/model/Interest.php
r12 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseInterest.php';3 require_once 'lib/model/om/BaseInterest.php'; 4 4 5 5 trunk/lib/model/InterestPeer.php
r4 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseInterestPeer.php';4 require_once 'lib/model/om/BaseInterestPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/Interest.php';7 include_once 'lib/model/Interest.php'; 8 8 9 9 trunk/lib/model/Question.php
r85 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseQuestion.php';3 require_once 'lib/model/om/BaseQuestion.php'; 4 4 5 5 trunk/lib/model/QuestionPeer.php
r82 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseQuestionPeer.php';4 require_once 'lib/model/om/BaseQuestionPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/Question.php';7 include_once 'lib/model/Question.php'; 8 8 9 9 … … 65 65 } 66 66 67 public function getPopular($max = 10)67 public static function getPopular($max = 10) 68 68 { 69 69 $c = new Criteria(); trunk/lib/model/QuestionTag.php
r58 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseQuestionTag.php';3 require_once 'lib/model/om/BaseQuestionTag.php'; 4 4 5 5 trunk/lib/model/QuestionTagPeer.php
r72 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseQuestionTagPeer.php';4 require_once 'lib/model/om/BaseQuestionTagPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/QuestionTag.php';7 include_once 'lib/model/QuestionTag.php'; 8 8 9 9 trunk/lib/model/Relevancy.php
r12 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseRelevancy.php';3 require_once 'lib/model/om/BaseRelevancy.php'; 4 4 5 5 trunk/lib/model/RelevancyPeer.php
r4 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseRelevancyPeer.php';4 require_once 'lib/model/om/BaseRelevancyPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/Relevancy.php';7 include_once 'lib/model/Relevancy.php'; 8 8 9 9 trunk/lib/model/ReportAnswer.php
r55 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseReportAnswer.php';3 require_once 'lib/model/om/BaseReportAnswer.php'; 4 4 5 5 trunk/lib/model/ReportAnswerPeer.php
r55 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseReportAnswerPeer.php';4 require_once 'lib/model/om/BaseReportAnswerPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/ReportAnswer.php';7 include_once 'lib/model/ReportAnswer.php'; 8 8 9 9 trunk/lib/model/ReportQuestion.php
r55 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseReportQuestion.php';3 require_once 'lib/model/om/BaseReportQuestion.php'; 4 4 5 5 trunk/lib/model/ReportQuestionPeer.php
r55 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseReportQuestionPeer.php';4 require_once 'lib/model/om/BaseReportQuestionPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/ReportQuestion.php';7 include_once 'lib/model/ReportQuestion.php'; 8 8 9 9 trunk/lib/model/SearchIndex.php
r58 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseSearchIndex.php';3 require_once 'lib/model/om/BaseSearchIndex.php'; 4 4 5 5 trunk/lib/model/SearchIndexPeer.php
r58 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseSearchIndexPeer.php';4 require_once 'lib/model/om/BaseSearchIndexPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/SearchIndex.php';7 include_once 'lib/model/SearchIndex.php'; 8 8 9 9 trunk/lib/model/User.php
r69 r88 1 1 <?php 2 2 3 require_once ' model/om/BaseUser.php';3 require_once 'lib/model/om/BaseUser.php'; 4 4 5 5 trunk/lib/model/UserPeer.php
r55 r88 2 2 3 3 // include base peer class 4 require_once ' model/om/BaseUserPeer.php';4 require_once 'lib/model/om/BaseUserPeer.php'; 5 5 6 6 // include object class 7 include_once ' model/User.php';7 include_once 'lib/model/User.php'; 8 8 9 9 trunk/lib/model/map/AnswerMapBuilder.php
r55 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_answer' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class AnswerMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.AnswerMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.AnswerMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 83 51 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 84 52 85 } // doBuild() 86 87 } // AnswerMapBuilder 53 } 54 } trunk/lib/model/map/InterestMapBuilder.php
r4 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_interest' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class InterestMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.InterestMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.InterestMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 71 39 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 72 40 73 } // doBuild() 74 75 } // InterestMapBuilder 41 } 42 } trunk/lib/model/map/QuestionMapBuilder.php
r55 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_question' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class QuestionMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.QuestionMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.QuestionMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 85 53 $tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false); 86 54 87 } // doBuild() 88 89 } // QuestionMapBuilder 55 } 56 } trunk/lib/model/map/QuestionTagMapBuilder.php
r55 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_question_tag' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class QuestionTagMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.QuestionTagMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.QuestionTagMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 75 43 $tMap->addPrimaryKey('NORMALIZED_TAG', 'NormalizedTag', 'string', CreoleTypes::VARCHAR, true, 100); 76 44 77 } // doBuild() 78 79 } // QuestionTagMapBuilder 45 } 46 } trunk/lib/model/map/RelevancyMapBuilder.php
r20 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_relevancy' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class RelevancyMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.RelevancyMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.RelevancyMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 73 41 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 74 42 75 } // doBuild() 76 77 } // RelevancyMapBuilder 43 } 44 } trunk/lib/model/map/ReportAnswerMapBuilder.php
r55 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_report_answer' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class ReportAnswerMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.ReportAnswerMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.ReportAnswerMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 71 39 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 72 40 73 } // doBuild() 74 75 } // ReportAnswerMapBuilder 41 } 42 } trunk/lib/model/map/ReportQuestionMapBuilder.php
r55 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_report_question' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class ReportQuestionMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.ReportQuestionMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.ReportQuestionMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 71 39 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 72 40 73 } // doBuild() 74 75 } // ReportQuestionMapBuilder 41 } 42 } trunk/lib/model/map/SearchIndexMapBuilder.php
r58 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_search_index' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class SearchIndexMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.SearchIndexMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.SearchIndexMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 71 39 $tMap->addColumn('WEIGHT', 'Weight', 'int', CreoleTypes::INTEGER, false); 72 40 73 } // doBuild() 74 75 } // SearchIndexMapBuilder 41 } 42 } trunk/lib/model/map/UserMapBuilder.php
r55 r88 1 1 <?php 2 3 require_once 'propel/map/MapBuilder.php';4 include_once 'creole/CreoleTypes.php';5 2 6 3 7 /** 8 * This class adds structure of 'ask_user' table to 'symfony' DatabaseMap object. 9 * 10 * 11 * 12 * These statically-built map classes are used by Propel to do runtime db structure discovery. 13 * For example, the createSelectSql() method checks the type of a given column used in an 14 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive 15 * (i.e. if it's a text column type). 16 * 17 * @package model.map 18 */ 4 19 5 class UserMapBuilder { 20 6 21 /** 22 * The (dot-path) name of this class 23 */ 24 const CLASS_NAME = 'model.map.UserMapBuilder'; 7 8 const CLASS_NAME = 'lib.model.map.UserMapBuilder'; 25 9 26 /** 27 * The database map. 28 */ 10 29 11 private $dbMap; 30 12 31 /** 32 * Tells us if this DatabaseMapBuilder is built so that we 33 * don't have to re-build it every time. 34 * 35 * @return boolean true if this DatabaseMapBuilder is built, false otherwise. 36 */ 13 37 14 public function isBuilt() 38 15 { … … 40 17 } 41 18 42 /** 43 * Gets the databasemap this map builder built. 44 * 45 * @return the databasemap 46 */ 19 47 20 public function getDatabaseMap() 48 21 { … … 50 23 } 51 24 52 /** 53 * The doBuild() method builds the DatabaseMap 54 * 55 * @return void 56 * @throws PropelException 57 */ 25 58 26 public function doBuild() 59 27 { … … 91 59 $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); 92 60 93 } // doBuild() 94 95 } // UserMapBuilder 61 } 62 } trunk/lib/model/om/BaseAnswer.php
r74 r88 1 1 <?php 2 2 3 require_once 'propel/om/BaseObject.php'; 4 5 require_once 'propel/om/Persistent.php'; 6 7 8 include_once 'propel/util/Criteria.php'; 9 10 include_once 'model/AnswerPeer.php'; 11 12 /** 13 * Base class that represents a row from the 'ask_answer' table. 14 * 15 * 16 * 17 * @package model.om 18 */ 3 19 4 abstract class BaseAnswer extends BaseObject implements Persistent { 20 5 21 6 22 /** 23 * The Peer class. 24 * Instance provides a convenient way of calling static methods on a class 25 * that calling code may not be able to identify. 26 * @var AnswerPeer 27 */ 7 8 const DATABASE_NAME = 'symfony'; 9 10 28 11 protected static $peer; 29 12 30 13 31 /** 32 * The value for the id field. 33 * @var int 34 */ 14 35 15 protected $id; 36 16 37 17 38 /** 39 * The value for the question_id field. 40 * @var int 41 */ 18 42 19 protected $question_id; 43 20 44 21 45 /** 46 * The value for the user_id field. 47 * @var int 48 */ 22 49 23 protected $user_id; 50 24 51 25 52 /** 53 * The value for the body field. 54 * @var string 55 */ 26 56 27 protected $body; 57 28 58 29 59 /** 60 * The value for the html_body field. 61 * @var string 62 */ 30 63 31 protected $html_body; 64 32 65 33 66 /** 67 * The value for the relevancy_up field. 68 * @var int 69 */ 34 70 35 protected $relevancy_up = 0; 71 36 72 37 73 /** 74 * The value for the relevancy_down field. 75 * @var int 76 */ 38 77 39 protected $relevancy_down = 0; 78 40 79 41 80 /** 81 * The value for the reports field. 82 * @var int 83 */ 42 84 43 protected $reports = 0; 85 44 86 45 87 /** 88 * The value for the created_at field. 89 * @var int 90 */ 46 91 47 protected $created_at; 92 48 93 /** 94 * @var Question 95 */ 49 96 50 protected $aQuestion; 97 51 98 /** 99 * @var User 100 */ 52 101 53 protected $aUser; 102 54 103 /** 104 * Collection to store aggregation of collRelevancys. 105 * @var array 106 */ 55 107 56 protected $collRelevancys; 108 109 /** 110 * The criteria used to select the current contents of collRelevancys. 111 * @var Criteria 112 */ 113 private $lastRelevancyCriteria = null; 114 115 /** 116 * Collection to store aggregation of collReportAnswers. 117 * @var array 118 */ 57 58 59 protected $lastRelevancyCriteria = null; 60 61 119 62 protected $collReportAnswers; 120 121 /** 122 * The criteria used to select the current contents of collReportAnswers. 123 * @var Criteria 124 */ 125 private $lastReportAnswerCriteria = null; 126 127 /** 128 * Flag to prevent endless save loop, if this object is referenced 129 * by another object which falls in this transaction. 130 * @var boolean 131 */ 63 64 65 protected $lastReportAnswerCriteria = null; 66 67 132 68 protected $alreadyInSave = false; 133 69 134 /** 135 * Flag to prevent endless validation loop, if this object is referenced 136 * by another object which falls in this transaction. 137 * @var boolean 138 */ 70 139 71 protected $alreadyInValidation = false; 140 72 141 /** 142 * Get the [id] column value. 143 * 144 * @return int 145 */ 73 146 74 public function getId() 147 75 { … … 150 78 } 151 79 152 /** 153 * Get the [question_id] column value. 154 * 155 * @return int 156 */ 80 157 81 public function getQuestionId() 158 82 { … … 161 85 } 162 86 163 /** 164 * Get the [user_id] column value. 165 * 166 * @return int 167 */ 87 168 88 public function getUserId() 169 89 { … … 172 92 } 173 93 174 /** 175 * Get the [body] column value. 176 * 177 * @return string 178 */ 94 179 95 public function getBody() 180 96 { … … 183 99 } 184 100 185 /** 186 * Get the [html_body] column value. 187 * 188 * @return string 189 */ 101 190 102 public function getHtmlBody() 191 103 { … … 194 106 } 195 107 196 /** 197 * Get the [relevancy_up] column value. 198 * 199 * @return int 200 */ 108 201 109 public function getRelevancyUp() 202 110 { … … 205 113 } 206 114 207 /** 208 * Get the [relevancy_down] column value. 209 * 210 * @return int 211 */ 115 212 116 public function getRelevancyDown() 213 117 { … … 216 120 } 217 121 218 /** 219 * Get the [reports] column value. 220 * 221 * @return int 222 */ 122 223 123 public function getReports() 224 124 { … … 227 127 } 228 128 229 /** 230 * Get the [optionally formatted] [created_at] column value. 231 * 232 * @param string $format The date/time format string (either date()-style or strftime()-style). 233 * If format is NULL, then the integer unix timestamp will be returned. 234 * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). 235 * @throws PropelException - if unable to convert the date/time to timestamp. 236 */ 129 237 130 public function getCreatedAt($format = 'Y-m-d H:i:s') 238 131 { … … 241 134 return null; 242 135 } elseif (!is_int($this->created_at)) { 243 // a non-timestamp value was set externally, so we convert it 244 $ts = strtotime($this->created_at); 245 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 246 throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); 136 $ts = strtotime($this->created_at); 137 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); 247 138 } 248 139 } else { … … 258 149 } 259 150 260 /** 261 * Set the value of [id] column. 262 * 263 * @param int $v new value 264 * @return void 265 */ 151 266 152 public function setId($v) 267 153 { … … 272 158 } 273 159 274 } // setId() 275 276 /** 277 * Set the value of [question_id] column. 278 * 279 * @param int $v new value 280 * @return void 281 */ 160 } 161 282 162 public function setQuestionId($v) 283 163 { … … 290 170 if ($this->aQuestion !== null && $this->aQuestion->getId() !== $v) { 291 171 $this->aQuestion = null; 292 } 293 294 } // setQuestionId() 295 296 /** 297 * Set the value of [user_id] column. 298 * 299 * @param int $v new value 300 * @return void 301 */ 172 } 173 174 } 175 302 176 public function setUserId($v) 303 177 { … … 310 184 if ($this->aUser !== null && $this->aUser->getId() !== $v) { 311 185 $this->aUser = null; 312 } 313 314 } // setUserId() 315 316 /** 317 * Set the value of [body] column. 318 * 319 * @param string $v new value 320 * @return void 321 */ 186 } 187 188 } 189 322 190 public function setBody($v) 323 191 { … … 328 196 } 329 197 330 } // setBody() 331 332 /** 333 * Set the value of [html_body] column. 334 * 335 * @param string $v new value 336 * @return void 337 */ 198 } 199 338 200 public function setHtmlBody($v) 339 201 { … … 344 206 } 345 207 346 } // setHtmlBody() 347 348 /** 349 * Set the value of [relevancy_up] column. 350 * 351 * @param int $v new value 352 * @return void 353 */ 208 } 209 354 210 public function setRelevancyUp($v) 355 211 { … … 360 216 } 361 217 362 } // setRelevancyUp() 363 364 /** 365 * Set the value of [relevancy_down] column. 366 * 367 * @param int $v new value 368 * @return void 369 */ 218 } 219 370 220 public function setRelevancyDown($v) 371 221 { … … 376 226 } 377 227 378 } // setRelevancyDown() 379 380 /** 381 * Set the value of [reports] column. 382 * 383 * @param int $v new value 384 * @return void 385 */ 228 } 229 386 230 public function setReports($v) 387 231 { … … 392 236 } 393 237 394 } // setReports() 395 396 /** 397 * Set the value of [created_at] column. 398 * 399 * @param int $v new value 400 * @return void 401 */ 238 } 239 402 240 public function setCreatedAt($v) 403 241 { … … 405 243 if ($v !== null && !is_int($v)) { 406 244 $ts = strtotime($v); 407 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 408 throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); 245 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); 409 246 } 410 247 } else { … … 416 253 } 417 254 418 } // setCreatedAt() 419 420 /** 421 * Hydrates (populates) the object variables with values from the database resultset. 422 * 423 * An offset (1-based "start column") is specified so that objects can be hydrated 424 * with a subset of the columns in the resultset rows. This is needed, for example, 425 * for results of JOIN queries where the resultset row includes columns from two or 426 * more tables. 427 * 428 * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. 429 * @param int $startcol 1-based offset column which indicates which restultset column to start with. 430 * @return int next starting column 431 * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. 432 */ 255 } 256 433 257 public function hydrate(ResultSet $rs, $startcol = 1) 434 258 { … … 457 281 $this->setNew(false); 458 282 459 // FIXME - using NUM_COLUMNS may be clearer. 460 return $startcol + 9; // 9 = AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS). 461 283 return $startcol + 9; 462 284 } catch (Exception $e) { 463 285 throw new PropelException("Error populating Answer object", $e); … … 465 287 } 466 288 467 /** 468 * Removes this object from datastore and sets delete attribute. 469 * 470 * @param Connection $con 471 * @return void 472 * @throws PropelException 473 * @see BaseObject::setDeleted() 474 * @see BaseObject::isDeleted() 475 */ 289 476 290 public function delete($con = null) 477 291 { … … 495 309 } 496 310 497 /** 498 * Stores the object in the database. If the object is new, 499 * it inserts it; otherwise an update is performed. This method 500 * wraps the doSave() worker method in a transaction. 501 * 502 * @param Connection $con 503 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. 504 * @throws PropelException 505 * @see doSave() 506 */ 311 507 312 public function save($con = null) 508 313 { 509 if ($this->isNew() )314 if ($this->isNew() && !$this->isColumnModified(AnswerPeer::CREATED_AT)) 510 315 { 511 316 $this->setCreatedAt(time()); … … 519 324 $con = Propel::getConnection(AnswerPeer::DATABASE_NAME); 520 325 } 521 326 522 327 try { 523 328 $con->begin(); … … 531 336 } 532 337 533 /** 534 * Stores the object in the database. 535 * 536 * If the object is new, it inserts it; otherwise an update is performed. 537 * All related objects are also updated in this method. 538 * 539 * @param Connection $con 540 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. 541 * @throws PropelException 542 * @see save() 543 */ 338 544 339 protected function doSave($con) 545 340 { 546 $affectedRows = 0; // initialize var to track total num of affected rows 547 if (!$this->alreadyInSave) { 341 $affectedRows = 0; if (!$this->alreadyInSave) { 548 342 $this->alreadyInSave = true; 549 343 550 344 551 // We call the save method on the following object(s) if they 552 // were passed to this object by their coresponding set 553 // method. This object relates to these object(s) by a 554 // foreign key reference. 555 345 556 346 if ($this->aQuestion !== null) { 557 347 if ($this->aQuestion->isModified()) { … … 567 357 $this->setUser($this->aUser); 568 358 } 569 570 571 // If this object has been modified, then save it to the database. 572 if ($this->isModified()) { 359 360 361 if ($this->isModified()) { 573 362 if ($this->isNew()) { 574 363 $pk = AnswerPeer::doInsert($this, $con); 575 $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which 576 // should always be true here (even though technically 577 // BasePeer::doInsert() can insert multiple rows). 578 579 $this->setId($pk); //[IMV] update autoincrement primary key 580 364 $affectedRows += 1; 365 $this->setId($pk); 581 366 $this->setNew(false); 582 367 } else { 583 368 $affectedRows += AnswerPeer::doUpdate($this, $con); 584 369 } 585 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 586 } 370 $this->resetModified(); } 587 371 588 372 if ($this->collRelevancys !== null) { … … 605 389 } 606 390 return $affectedRows; 607 } // doSave() 608 609 /** 610 * Array of ValidationFailed objects. 611 * @var array ValidationFailed[] 612 */ 391 } 392 613 393 protected $validationFailures = array(); 614 394 615 /** 616 * Gets any ValidationFailed objects that resulted from last call to validate(). 617 * 618 * 619 * @return array ValidationFailed[] 620 * @see validate() 621 */ 395 622 396 public function getValidationFailures() 623 397 { … … 625 399 } 626 400 627 /** 628 * Validates the objects modified field values and all objects related to this table. 629 * 630 * If $columns is either a column name or an array of column names 631 * only those columns are validated. 632 * 633 * @param mixed $columns Column name or an array of column names. 634 * @return boolean Whether all columns pass validation. 635 * @see doValidate() 636 * @see getValidationFailures() 637 */ 401 638 402 public function validate($columns = null) 639 403 { … … 648 412 } 649 413 650 /** 651 * This function performs the validation work for complex object models. 652 * 653 * In addition to checking the current object, all related objects will 654 * also be validated. If all pass then <code>true</code> is returned; otherwise 655 * an aggreagated array of ValidationFailed objects will be returned. 656 * 657 * @param array $columns Array of column names to validate. 658 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 659 */ 414 660 415 protected function doValidate($columns = null) 661 416 { … … 667 422 668 423 669 // We call the validate method on the following object(s) if they 670 // were passed to this object by their coresponding set 671 // method. This object relates to these object(s) by a 672 // foreign key reference. 673 424 674 425 if ($this->aQuestion !== null) { 675 426 if (!$this->aQuestion->validate($columns)) { … … 713 464 } 714 465 715 /** 716 * Retrieves a field from the object by name passed in as a string. 717 * 718 * @param string $name name 719 * @param string $type The type of fieldname the $name is of: 720 * one of the class type constants TYPE_PHPNAME, 721 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 722 * @return mixed Value of field. 723 */ 466 724 467 public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 725 468 { … … 728 471 } 729 472 730 /** 731 * Retrieves a field from the object by Position as specified in the xml schema. 732 * Zero-based. 733 * 734 * @param int $pos position in xml schema 735 * @return mixed Value of field at $pos 736 */ 473 737 474 public function getByPosition($pos) 738 475 { … … 768 505 return null; 769 506 break; 770 } // switch() 771 } 772 773 /** 774 * Exports the object as an array. 775 * 776 * You can specify the key type of the array by passing one of the class 777 * type constants. 778 * 779 * @param string $keyType One of the class type constants TYPE_PHPNAME, 780 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 781 * @return an associative array containing the field names (as keys) and field values 782 */ 507 } } 508 509 783 510 public function toArray($keyType = BasePeer::TYPE_PHPNAME) 784 511 { … … 798 525 } 799 526 800 /** 801 * Sets a field from the object by name passed in as a string. 802 * 803 * @param string $name peer name 804 * @param mixed $value field value 805 * @param string $type The type of fieldname the $name is of: 806 * one of the class type constants TYPE_PHPNAME, 807 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 808 * @return void 809 */ 527 810 528 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 811 529 { … … 814 532 } 815 533 816 /** 817 * Sets a field from the object by Position as specified in the xml schema. 818 * Zero-based. 819 * 820 * @param int $pos position in xml schema 821 * @param mixed $value field value 822 * @return void 823 */ 534 824 535 public function setByPosition($pos, $value) 825 536 { … … 852 563 $this->setCreatedAt($value); 853 564 break; 854 } // switch() 855 } 856 857 /** 858 * Populates the object using an array. 859 * 860 * This is particularly useful when populating an object from one of the 861 * request arrays (e.g. $_POST). This method goes through the column 862 * names, checking to see whether a matching key exists in populated 863 * array. If so the setByName() method is called for that column. 864 * 865 * You can specify the key type of the array by additionally passing one 866 * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, 867 * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') 868 * 869 * @param array $arr An array to populate the object from. 870 * @param string $keyType The type of keys the array uses. 871 * @return void 872 */ 565 } } 566 567 873 568 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) 874 569 { … … 886 581 } 887 582 888 /** 889 * Build a Criteria object containing the values of all modified columns in this object. 890 * 891 * @return Criteria The Criteria object containing all modified values. 892 */ 583 893 584 public function buildCriteria() 894 585 { … … 908 599 } 909 600 910 /** 911 * Builds a Criteria object containing the primary key for this object. 912 * 913 * Unlike buildCriteria() this method includes the primary key values regardless 914 * of whether or not they have been modified. 915 * 916 * @return Criteria The Criteria object containing value(s) for primary key(s). 917 */ 601 918 602 public function buildPkeyCriteria() 919 603 { … … 925 609 } 926 610 927 /** 928 * Returns the primary key for this object (row). 929 * @return int 930 */ 611 931 612 public function getPrimaryKey() 932 613 { … … 934 615 } 935 616 936 /** 937 * Generic method to set the primary key (id column). 938 * 939 * @param int $key Primary key. 940 * @return void 941 */ 617 942 618 public function setPrimaryKey($key) 943 619 { … … 945 621 } 946 622 947 /** 948 * Sets contents of passed object to values from current object. 949 * 950 * If desired, this method can also make copies of all associated (fkey referrers) 951 * objects. 952 * 953 * @param object $copyObj An object of Answer (or compatible) type. 954 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 955 * @throws PropelException 956 */ 623 957 624 public function copyInto($copyObj, $deepCopy = false) 958 625 { … … 976 643 977 644 if ($deepCopy) { 978 // important: temporarily setNew(false) because this affects the behavior of 979 // the getter/setter methods for fkey referrer objects. 980 $copyObj->setNew(false); 645 $copyObj->setNew(false); 981 646 982 647 foreach($this->getRelevancys() as $relObj) { 983 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 984 $copyObj->addRelevancy($relObj->copy($deepCopy)); 985 } 648 $copyObj->addRelevancy($relObj->copy($deepCopy)); 986 649 } 987 650 988 651 foreach($this->getReportAnswers() as $relObj) { 989 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 990 $copyObj->addReportAnswer($relObj->copy($deepCopy)); 991 } 992 } 993 994 } // if ($deepCopy) 995 652 $copyObj->addReportAnswer($relObj->copy($deepCopy)); 653 } 654 655 } 996 656 997 657 $copyObj->setNew(true); 998 658 999 $copyObj->setId(NULL); // this is a pkey column, so set to default value 1000 1001 } 1002 1003 /** 1004 * Makes a copy of this object that will be inserted as a new row in table when saved. 1005 * It creates a new object filling in the simple attributes, but skipping any primary 1006 * keys that are defined for the table. 1007 * 1008 * If desired, this method can also make copies of all associated (fkey referrers) 1009 * objects. 1010 * 1011 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 1012 * @return Answer Clone of current object. 1013 * @throws PropelException 1014 */ 659 $copyObj->setId(NULL); 660 } 661 662 1015 663 public function copy($deepCopy = false) 1016 664 { 1017 // we use get_class(), because this might be a subclass 1018 $clazz = get_class($this); 665 $clazz = get_class($this); 1019 666 $copyObj = new $clazz(); 1020 667 $this->copyInto($copyObj, $deepCopy); … … 1022 669 } 1023 670 1024 /** 1025 * Returns a peer instance associated with this om. 1026 * 1027 * Since Peer classes are not to have any instance attributes, this method returns the 1028 * same instance for all member of this class. The method could therefore 1029 * be static, but this would prevent one from overriding the behavior. 1030 * 1031 * @return AnswerPeer 1032 */ 671 1033 672 public function getPeer() 1034 673 { … … 1039 678 } 1040 679 1041 /** 1042 * Declares an association between this object and a Question object. 1043 * 1044 * @param Question $v 1045 * @return void 1046 * @throws PropelException 1047 */ 680 1048 681 public function setQuestion($v) 1049 682 { … … 1061 694 1062 695 1063 /** 1064 * Get the associated Question object 1065 * 1066 * @param Connection Optional Connection object. 1067 * @return Question The associated Question object. 1068 * @throws PropelException 1069 */ 696 1070 697 public function getQuestion($con = null) 1071 698 { 1072 // include the related Peer class 1073 include_once 'model/om/BaseQuestionPeer.php'; 699 include_once 'lib/model/om/BaseQuestionPeer.php'; 1074 700 1075 701 if ($this->aQuestion === null && ($this->question_id !== null)) { 1076 702 1077 703 $this->aQuestion = QuestionPeer::retrieveByPK($this->question_id, $con); 1078 1079 /* The following can be used instead of the line above to 1080 guarantee the related object contains a reference 1081 to this object, but this level of coupling 1082 may be undesirable in many circumstances. 1083 As it can lead to a db query with many results that may 1084 never be used. 1085 $obj = QuestionPeer::retrieveByPK($this->question_id, $con); 1086 $obj->addQuestions($this); 1087 */ 704 705 1088 706 } 1089 707 return $this->aQuestion; 1090 708 } 1091 709 1092 /** 1093 * Declares an association between this object and a User object. 1094 * 1095 * @param User $v 1096 * @return void 1097 * @throws PropelException 1098 */ 710 1099 711 public function setUser($v) 1100 712 { … … 1112 724 1113 725 1114 /** 1115 * Get the associated User object 1116 * 1117 * @param Connection Optional Connection object. 1118 * @return User The associated User object. 1119 * @throws PropelException 1120 */ 726 1121 727 public function getUser($con = null) 1122 728 { 1123 // include the related Peer class 1124 include_once 'model/om/BaseUserPeer.php'; 729 include_once 'lib/model/om/BaseUserPeer.php'; 1125 730 1126 731 if ($this->aUser === null && ($this->user_id !== null)) { 1127 732 1128 733 $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); 1129 1130 /* The following can be used instead of the line above to 1131 guarantee the related object contains a reference 1132 to this object, but this level of coupling 1133 may be undesirable in many circumstances. 1134 As it can lead to a db query with many results that may 1135 never be used. 1136 $obj = UserPeer::retrieveByPK($this->user_id, $con); 1137 $obj->addUsers($this); 1138 */ 734 735 1139 736 } 1140 737 return $this->aUser; 1141 738 } 1142 739 1143 /** 1144 * Temporary storage of collRelevancys to save a possible db hit in 1145 * the event objects are add to the collection, but the 1146 * complete collection is never requested. 1147 * @return void 1148 */ 740 1149 741 public function initRelevancys() 1150 742 { … … 1154 746 } 1155 747 1156 /** 1157 * If this collection has already been initialized with 1158 * an identical criteria, it returns the collection. 1159 * Otherwise if this Answer has previously 1160 * been saved, it will retrieve related Relevancys from storage. 1161 * If this Answer is new, it will return 1162 * an empty collection or the current collection, the criteria 1163 * is ignored on a new object. 1164 * 1165 * @param Connection $con 1166 * @param Criteria $criteria 1167 * @throws PropelException 1168 */ 748 1169 749 public function getRelevancys($criteria = null, $con = null) 1170 750 { 1171 // include the Peer class 1172 include_once 'model/om/BaseRelevancyPeer.php'; 751 include_once 'lib/model/om/BaseRelevancyPeer.php'; 1173 752 if ($criteria === null) { 1174 753 $criteria = new Criteria(); … … 1190 769 } 1191 770 } else { 1192 // criteria has no effect for a new object 1193 if (!$this->isNew()) { 1194 // the following code is to determine if a new query is 1195 // called for. If the criteria is the same as the last 1196 // one, just return the collection. 1197 771 if (!$this->isNew()) { 772 1198 773 1199 774 $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); … … 1209 784 } 1210 785 1211 /** 1212 * Returns the number of related Relevancys. 1213 * 1214 * @param Criteria $criteria 1215 * @param boolean $distinct 1216 * @param Connection $con 1217 * @throws PropelException 1218 */ 786 1219 787 public function countRelevancys($criteria = null, $distinct = false, $con = null) 1220 788 { 1221 // include the Peer class 1222 include_once 'model/om/BaseRelevancyPeer.php'; 789 include_once 'lib/model/om/BaseRelevancyPeer.php'; 1223 790 if ($criteria === null) { 1224 791 $criteria = new Criteria(); … … 1234 801 } 1235 802 1236 /** 1237 * Method called to associate a Relevancy object to this object 1238 * through the Relevancy foreign key attribute 1239 * 1240 * @param Relevancy $l Relevancy 1241 * @return void 1242 * @throws PropelException 1243 */ 803 1244 804 public function addRelevancy(Relevancy $l) 1245 805 { … … 1249 809 1250 810 1251 /** 1252 * If this collection has already been initialized with 1253 * an identical criteria, it returns the collection. 1254 * Otherwise if this Answer is new, it will return 1255 * an empty collection; or if this Answer has previously 1256 * been saved, it will retrieve related Relevancys from storage. 1257 * 1258 * This method is protected by default in order to keep the public 1259 * api reasonable. You can provide public methods for those you 1260 * actually need in Answer. 1261 */ 811 1262 812 public function getRelevancysJoinUser($criteria = null, $con = null) 1263 813 { 1264 // include the Peer class 1265 include_once 'model/om/BaseRelevancyPeer.php'; 814 include_once 'lib/model/om/BaseRelevancyPeer.php'; 1266 815 if ($criteria === null) { 1267 816 $criteria = new Criteria(); … … 1282 831 } 1283 832 } else { 1284 // the following code is to determine if a new query is 1285 // called for. If the criteria is the same as the last 1286 // one, just return the collection. 1287 833 1288 834 $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); 1289 835 … … 1297 843 } 1298 844 1299 /** 1300 * Temporary storage of collReportAnswers to save a possible db hit in 1301 * the event objects are add to the collection, but the 1302 * complete collection is never requested. 1303 * @return void 1304 */ 845 1305 846 public function initReportAnswers() 1306 847 { … … 1310 851 } 1311 852 1312 /** 1313 * If this collection has already been initialized with 1314 * an identical criteria, it returns the collection. 1315 * Otherwise if this Answer has previously 1316 * been saved, it will retrieve related ReportAnswers from storage. 1317 * If this Answer is new, it will return 1318 * an empty collection or the current collection, the criteria 1319 * is ignored on a new object. 1320 * 1321 * @param Connection $con 1322 * @param Criteria $criteria 1323 * @throws PropelException 1324 */ 853 1325 854 public function getReportAnswers($criteria = null, $con = null) 1326 855 { 1327 // include the Peer class 1328 include_once 'model/om/BaseReportAnswerPeer.php'; 856 include_once 'lib/model/om/BaseReportAnswerPeer.php'; 1329 857 if ($criteria === null) { 1330 858 $criteria = new Criteria(); … … 1346 874 } 1347 875 } else { 1348 // criteria has no effect for a new object 1349 if (!$this->isNew()) { 1350 // the following code is to determine if a new query is 1351 // called for. If the criteria is the same as the last 1352 // one, just return the collection. 1353 876 if (!$this->isNew()) { 877 1354 878 1355 879 $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); … … 1365 889 } 1366 890 1367 /** 1368 * Returns the number of related ReportAnswers. 1369 * 1370 * @param Criteria $criteria 1371 * @param boolean $distinct 1372 * @param Connection $con 1373 * @throws PropelException 1374 */ 891 1375 892 public function countReportAnswers($criteria = null, $distinct = false, $con = null) 1376 893 { 1377 // include the Peer class 1378 include_once 'model/om/BaseReportAnswerPeer.php'; 894 include_once 'lib/model/om/BaseReportAnswerPeer.php'; 1379 895 if ($criteria === null) { 1380 896 $criteria = new Criteria(); … … 1390 906 } 1391 907 1392 /** 1393 * Method called to associate a ReportAnswer object to this object 1394 * through the ReportAnswer foreign key attribute 1395 * 1396 * @param ReportAnswer $l ReportAnswer 1397 * @return void 1398 * @throws PropelException 1399 */ 908 1400 909 public function addReportAnswer(ReportAnswer $l) 1401 910 { … … 1405 914 1406 915 1407 /** 1408 * If this collection has already been initialized with 1409 * an identical criteria, it returns the collection. 1410 * Otherwise if this Answer is new, it will return 1411 * an empty collection; or if this Answer has previously 1412 * been saved, it will retrieve related ReportAnswers from storage. 1413 * 1414 * This method is protected by default in order to keep the public 1415 * api reasonable. You can provide public methods for those you 1416 * actually need in Answer. 1417 */ 916 1418 917 public function getReportAnswersJoinUser($criteria = null, $con = null) 1419 918 { 1420 // include the Peer class 1421 include_once 'model/om/BaseReportAnswerPeer.php'; 919 include_once 'lib/model/om/BaseReportAnswerPeer.php'; 1422 920 if ($criteria === null) { 1423 921 $criteria = new Criteria(); … … 1438 936 } 1439 937 } else { 1440 // the following code is to determine if a new query is 1441 // called for. If the criteria is the same as the last 1442 // one, just return the collection. 1443 938 1444 939 $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); 1445 940 … … 1453 948 } 1454 949 1455 } // BaseAnswer950 } trunk/lib/model/om/BaseAnswerPeer.php
r74 r88 1 1 <?php 2 2 3 require_once 'propel/util/BasePeer.php'; 4 // The object class -- needed for instanceof checks in this class. 5 // actual class may be a subclass -- as returned by AnswerPeer::getOMClass() 6 include_once 'model/Answer.php'; 7 8 /** 9 * Base static class for performing query and update operations on the 'ask_answer' table. 10 * 11 * 12 * 13 * @package model.om 14 */ 3 15 4 abstract class BaseAnswerPeer { 16 5 17 /** the default database name for this class */6 18 7 const DATABASE_NAME = 'symfony'; 19 8 20 /** the table name for this class */9 21 10 const TABLE_NAME = 'ask_answer'; 22 11 23 /** A class that can be returned by this peer. */24 const CLASS_DEFAULT = ' model.Answer';25 26 /** The total number of columns. */12 13 const CLASS_DEFAULT = 'lib.model.Answer'; 14 15 27 16 const NUM_COLUMNS = 9; 28 17 29 /** The number of lazy-loaded columns. */18 30 19 const NUM_LAZY_LOAD_COLUMNS = 0; 31 20 32 21 33 /** the column name for the ID field */22 34 23 const ID = 'ask_answer.ID'; 35 24 36 /** the column name for the QUESTION_ID field */25 37 26 const QUESTION_ID = 'ask_answer.QUESTION_ID'; 38 27 39 /** the column name for the USER_ID field */28 40 29 const USER_ID = 'ask_answer.USER_ID'; 41 30 42 /** the column name for the BODY field */31 43 32 const BODY = 'ask_answer.BODY'; 44 33 45 /** the column name for the HTML_BODY field */34 46 35 const HTML_BODY = 'ask_answer.HTML_BODY'; 47 36 48 /** the column name for the RELEVANCY_UP field */37 49 38 const RELEVANCY_UP = 'ask_answer.RELEVANCY_UP'; 50 39 51 /** the column name for the RELEVANCY_DOWN field */40 52 41 const RELEVANCY_DOWN = 'ask_answer.RELEVANCY_DOWN'; 53 42 54 /** the column name for the REPORTS field */43 55 44 const REPORTS = 'ask_answer.REPORTS'; 56 45 57 /** the column name for the CREATED_AT field */46 58 47 const CREATED_AT = 'ask_answer.CREATED_AT'; 59 48 60 /** The PHP to DB Name Mapping */49 61 50 private static $phpNameMap = null; 62 51 63 52 64 /** 65 * holds an array of fieldnames 66 * 67 * first dimension keys are the type constants 68 * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' 69 */ 53 70 54 private static $fieldNames = array ( 71 55 BasePeer::TYPE_PHPNAME => array ('Id', 'QuestionId', 'UserId', 'Body', 'HtmlBody', 'RelevancyUp', 'RelevancyDown', 'Reports', 'CreatedAt', ), … … 75 59 ); 76 60 77 /** 78 * holds an array of keys for quick access to the fieldnames array 79 * 80 * first dimension keys are the type constants 81 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 82 */ 61 83 62 private static $fieldKeys = array ( 84 63 BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'QuestionId' => 1, 'UserId' => 2, 'Body' => 3, 'HtmlBody' => 4, 'RelevancyUp' => 5, 'RelevancyDown' => 6, 'Reports' => 7, 'CreatedAt' => 8, ), … … 88 67 ); 89 68 90 /** 91 * @return MapBuilder the map builder for this peer 92 * @throws PropelException Any exceptions caught during processing will be 93 * rethrown wrapped into a PropelException. 94 */ 69 95 70 public static function getMapBuilder() 96 71 { 97 include_once 'model/map/AnswerMapBuilder.php'; 98 return BasePeer::getMapBuilder('model.map.AnswerMapBuilder'); 99 } 100 /** 101 * Gets a map (hash) of PHP names to DB column names. 102 * 103 * @return array The PHP to DB name map for this peer 104 * @throws PropelException Any exceptions caught during processing will be 105 * rethrown wrapped into a PropelException. 106 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. 107 */ 72 include_once 'lib/model/map/AnswerMapBuilder.php'; 73 return BasePeer::getMapBuilder('lib.model.map.AnswerMapBuilder'); 74 } 75 108 76 public static function getPhpNameMap() 109 77 { … … 119 87 return self::$phpNameMap; 120 88 } 121 /** 122 * Translates a fieldname to another type 123 * 124 * @param string $name field name 125 * @param string $fromType One of the class type constants TYPE_PHPNAME, 126 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 127 * @param string $toType One of the class type constants 128 * @return string translated name of the field. 129 */ 89 130 90 static public function translateFieldName($name, $fromType, $toType) 131 91 { … … 138 98 } 139 99 140 /** 141 * Returns an array of of field names. 142 * 143 * @param string $type The type of fieldnames to return: 144 * One of the class type constants TYPE_PHPNAME, 145 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 146 * @return array A list of field names 147 */ 100 148 101 149 102 static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) … … 155 108 } 156 109 157 /** 158 * Convenience method which changes table.column to alias.column. 159 * 160 * Using this method you can maintain SQL abstraction while using column aliases. 161 * <code> 162 * $c->addAlias("alias1", TablePeer::TABLE_NAME); 163 * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); 164 * </code> 165 * @param string $alias The alias for the current table. 166 * @param string $column The column name for current table. (i.e. AnswerPeer::COLUMN_NAME). 167 * @return string 168 */ 110 169 111 public static function alias($alias, $column) 170 112 { … … 172 114 } 173 115 174 /** 175 * Add all the columns needed to create a new object. 176 * 177 * Note: any columns that were marked with lazyLoad="true" in the 178 * XML schema will not be added to the select list and only loaded 179 * on demand. 180 * 181 * @param criteria object containing the columns to add. 182 * @throws PropelException Any exceptions caught during processing will be 183 * rethrown wrapped into a PropelException. 184 */ 116 185 117 public static function addSelectColumns(Criteria $criteria) 186 118 { … … 209 141 const COUNT_DISTINCT = 'COUNT(DISTINCT ask_answer.ID)'; 210 142 211 /** 212 * Returns the number of rows matching criteria. 213 * 214 * @param Criteria $criteria 215 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 216 * @param Connection $con 217 * @return int Number of matching rows. 218 */ 143 219 144 public static function doCount(Criteria $criteria, $distinct = false, $con = null) 220 145 { 221 // we're going to modify criteria, so copy it first 222 $criteria = clone $criteria; 223 224 // clear out anything that might confuse the ORDER BY clause 225 $criteria->clearSelectColumns()->clearOrderByColumns(); 146 $criteria = clone $criteria; 147 148 $criteria->clearSelectColumns()->clearOrderByColumns(); 226 149 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 227 150 $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); … … 230 153 } 231 154 232 // just in case we're grouping: add those columns to the select statement 233 foreach($criteria->getGroupByColumns() as $column) 155 foreach($criteria->getGroupByColumns() as $column) 234 156 { 235 157 $criteria->addSelectColumn($column); … … 240 162 return $rs->getInt(1); 241 163 } else { 242 // no rows returned; we infer that means 0 matches. 243 return 0; 244 } 245 } 246 /** 247 * Method to select one object from the DB. 248 * 249 * @param Criteria $criteria object used to create the SELECT statement. 250 * @param Connection $con 251 * @return Answer 252 * @throws PropelException Any exceptions caught during processing will be 253 * rethrown wrapped into a PropelException. 254 */ 164 return 0; 165 } 166 } 167 255 168 public static function doSelectOne(Criteria $criteria, $con = null) 256 169 { … … 263 176 return null; 264 177 } 265 /** 266 * Method to do selects. 267 * 268 * @param Criteria $criteria The Criteria object used to build the SELECT statement. 269 * @param Connection $con 270 * @return array Array of selected Objects 271 * @throws PropelException Any exceptions caught during processing will be 272 * rethrown wrapped into a PropelException. 273 */ 178 274 179 public static function doSelect(Criteria $criteria, $con = null) 275 180 { 276 181 return AnswerPeer::populateObjects(AnswerPeer::doSelectRS($criteria, $con)); 277 182 } 278 /** 279 * Prepares the Criteria object and uses the parent doSelect() 280 * method to get a ResultSet. 281 * 282 * Use this method directly if you want to just get the resultset 283 * (instead of an array of objects). 284 * 285 * @param Criteria $criteria The Criteria object used to build the SELECT statement. 286 * @param Connection $con the connection to use 287 * @throws PropelException Any exceptions caught during processing will be 288 * rethrown wrapped into a PropelException. 289 * @return ResultSet The resultset object with numerically-indexed fields. 290 * @see BasePeer::doSelect() 291 */ 183 292 184 public static function doSelectRS(Criteria $criteria, $con = null) 293 185 { … … 301 193 } 302 194 303 // Set the correct dbName 304 $criteria->setDbName(self::DATABASE_NAME); 305 306 // BasePeer returns a Creole ResultSet, set to return 307 // rows indexed numerically. 308 return BasePeer::doSelect($criteria, $con); 309 } 310 /** 311 * The returned array will contain objects of the default type or 312 * objects that inherit from the default. 313 * 314 * @throws PropelException Any exceptions caught during processing will be 315 * rethrown wrapped into a PropelException. 316 */ 195 $criteria->setDbName(self::DATABASE_NAME); 196 197 return BasePeer::doSelect($criteria, $con); 198 } 199 317 200 public static function populateObjects(ResultSet $rs) 318 201 { 319 202 $results = array(); 320 203 321 // set the class once to avoid overhead in the loop 322 $cls = AnswerPeer::getOMClass(); 204 $cls = AnswerPeer::getOMClass(); 323 205 $cls = Propel::import($cls); 324 // populate the object(s) 325 while($rs->next()) { 206 while($rs->next()) { 326 207 327 208 $obj = new $cls(); … … 333 214 } 334 215 335 /** 336 * Returns the number of rows matching criteria, joining the related Question table 337 * 338 * @param Criteria $c 339 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 340 * @param Connection $con 341 * @return int Number of matching rows. 342 */ 216 343 217 public static function doCountJoinQuestion(Criteria $criteria, $distinct = false, $con = null) 344 218 { 345 // we're going to modify criteria, so copy it first 346 $criteria = clone $criteria; 347 348 // clear out anything that might confuse the ORDER BY clause 349 $criteria->clearSelectColumns()->clearOrderByColumns(); 219 $criteria = clone $criteria; 220 221 $criteria->clearSelectColumns()->clearOrderByColumns(); 350 222 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 351 223 $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); … … 354 226 } 355 227 356 // just in case we're grouping: add those columns to the select statement 357 foreach($criteria->getGroupByColumns() as $column) 228 foreach($criteria->getGroupByColumns() as $column) 358 229 { 359 230 $criteria->addSelectColumn($column); … … 366 237 return $rs->getInt(1); 367 238 } else { 368 // no rows returned; we infer that means 0 matches. 369 return 0; 370 } 371 } 372 373 374 /** 375 * Returns the number of rows matching criteria, joining the related User table 376 * 377 * @param Criteria $c 378 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 379 * @param Connection $con 380 * @return int Number of matching rows. 381 */ 239 return 0; 240 } 241 } 242 243 244 382 245 public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) 383 246 { 384 // we're going to modify criteria, so copy it first 385 $criteria = clone $criteria; 386 387 // clear out anything that might confuse the ORDER BY clause 388 $criteria->clearSelectColumns()->clearOrderByColumns(); 247 $criteria = clone $criteria; 248 249 $criteria->clearSelectColumns()->clearOrderByColumns(); 389 250 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 390 251 $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); … … 393 254 } 394 255 395 // just in case we're grouping: add those columns to the select statement 396 foreach($criteria->getGroupByColumns() as $column) 256 foreach($criteria->getGroupByColumns() as $column) 397 257 { 398 258 $criteria->addSelectColumn($column); … … 405 265 return $rs->getInt(1); 406 266 } else { 407 // no rows returned; we infer that means 0 matches. 408 return 0; 409 } 410 } 411 412 413 /** 414 * Selects a collection of Answer objects pre-filled with their Question objects. 415 * 416 * @return array Array of Answer objects. 417 * @throws PropelException Any exceptions caught during processing will be 418 * rethrown wrapped into a PropelException. 419 */ 267 return 0; 268 } 269 } 270 271 272 420 273 public static function doSelectJoinQuestion(Criteria $c, $con = null) 421 274 { 422 275 $c = clone $c; 423 276 424 // Set the correct dbName if it has not been overridden 425 if ($c->getDbName() == Propel::getDefaultDB()) { 277 if ($c->getDbName() == Propel::getDefaultDB()) { 426 278 $c->setDbName(self::DATABASE_NAME); 427 279 } … … 451 303 $newObject = true; 452 304 foreach($results as $temp_obj1) { 453 $temp_obj2 = $temp_obj1->getQuestion(); //CHECKME 454 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 305 $temp_obj2 = $temp_obj1->getQuestion(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 455 306 $newObject = false; 456 // e.g. $author->addBookRelatedByBookId() 457 $temp_obj2->addAnswer($obj1); //CHECKME 458 break; 307 $temp_obj2->addAnswer($obj1); break; 459 308 } 460 309 } 461 310 if ($newObject) { 462 311 $obj2->initAnswers(); 463 $obj2->addAnswer($obj1); //CHECKME 464 } 312 $obj2->addAnswer($obj1); } 465 313 $results[] = $obj1; 466 314 } … … 469 317 470 318 471 /** 472 * Selects a collection of Answer objects pre-filled with their User objects. 473 * 474 * @return array Array of Answer objects. 475 * @throws PropelException Any exceptions caught during processing will be 476 * rethrown wrapped into a PropelException. 477 */ 319 478 320 public static function doSelectJoinUser(Criteria $c, $con = null) 479 321 { 480 322 $c = clone $c; 481 323 482 // Set the correct dbName if it has not been overridden 483 if ($c->getDbName() == Propel::getDefaultDB()) { 324 if ($c->getDbName() == Propel::getDefaultDB()) { 484 325 $c->setDbName(self::DATABASE_NAME); 485 326 } … … 509 350 $newObject = true; 510 351 foreach($results as $temp_obj1) { 511 $temp_obj2 = $temp_obj1->getUser(); //CHECKME 512 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 352 $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 513 353 $newObject = false; 514 // e.g. $author->addBookRelatedByBookId() 515 $temp_obj2->addAnswer($obj1); //CHECKME 516 break; 354 $temp_obj2->addAnswer($obj1); break; 517 355 } 518 356 } 519 357 if ($newObject) { 520 358 $obj2->initAnswers(); 521 $obj2->addAnswer($obj1); //CHECKME 522 } 359 $obj2->addAnswer($obj1); } 523 360 $results[] = $obj1; 524 361 } … … 527 364 528 365 529 /** 530 * Returns the number of rows matching criteria, joining all related tables 531 * 532 * @param Criteria $c 533 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 534 * @param Connection $con 535 * @return int Number of matching rows. 536 */ 366 537 367 public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) 538 368 { 539 369 $criteria = clone $criteria; 540 370 541 // clear out anything that might confuse the ORDER BY clause 542 $criteria->clearSelectColumns()->clearOrderByColumns(); 371 $criteria->clearSelectColumns()->clearOrderByColumns(); 543 372 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 544 373 $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); … … 547 376 } 548 377 549 // just in case we're grouping: add those columns to the select statement 550 foreach($criteria->getGroupByColumns() as $column) 378 foreach($criteria->getGroupByColumns() as $column) 551 379 { 552 380 $criteria->addSelectColumn($column); … … 561 389 return $rs->getInt(1); 562 390 } else { 563 // no rows returned; we infer that means 0 matches. 564 return 0; 565 } 566 } 567 568 569 /** 570 * Selects a collection of Answer objects pre-filled with all related objects. 571 * 572 * @return array Array of Answer objects. 573 * @throws PropelException Any exceptions caught during processing will be 574 * rethrown wrapped into a PropelException. 575 */ 391 return 0; 392 } 393 } 394 395 396 576 397 public static function doSelectJoinAll(Criteria $c, $con = null) 577 398 { 578 399 $c = clone $c; 579 400 580 // Set the correct dbName if it has not been overridden 581 if ($c->getDbName() == Propel::getDefaultDB()) { 401 if ($c->getDbName() == Propel::getDefaultDB()) { 582 402 $c->setDbName(self::DATABASE_NAME); 583 403 } … … 609 429 610 430 611 // Add objects for joined Question rows 612 431 613 432 $omClass = QuestionPeer::getOMClass(); 614 433 … … 621 440 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 622 441 $temp_obj1 = $results[$j]; 623 $temp_obj2 = $temp_obj1->getQuestion(); // CHECKME 624 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 442 $temp_obj2 = $temp_obj1->getQuestion(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 625 443 $newObject = false; 626 $temp_obj2->addAnswer($obj1); // CHECKME 627 break; 444 $temp_obj2->addAnswer($obj1); break; 628 445 } 629 446 } … … 635 452 636 453 637 // Add objects for joined User rows 638 454 639 455 $omClass = UserPeer::getOMClass(); 640 456 … … 647 463 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 648 464 $temp_obj1 = $results[$j]; 649 $temp_obj3 = $temp_obj1->getUser(); // CHECKME 650 if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { 465 $temp_obj3 = $temp_obj1->getUser(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { 651 466 $newObject = false; 652 $temp_obj3->addAnswer($obj1); // CHECKME 653 break; 467 $temp_obj3->addAnswer($obj1); break; 654 468 } 655 469 } … … 666 480 667 481 668 /** 669 * Returns the number of rows matching criteria, joining the related Question table 670 * 671 * @param Criteria $c 672 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 673 * @param Connection $con 674 * @return int Number of matching rows. 675 */ 482 676 483 public static function doCountJoinAllExceptQuestion(Criteria $criteria, $distinct = false, $con = null) 677 484 { 678 // we're going to modify criteria, so copy it first 679 $criteria = clone $criteria; 680 681 // clear out anything that might confuse the ORDER BY clause 682 $criteria->clearSelectColumns()->clearOrderByColumns(); 485 $criteria = clone $criteria; 486 487 $criteria->clearSelectColumns()->clearOrderByColumns(); 683 488 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 684 489 $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); … … 687 492 } 688 493 689 // just in case we're grouping: add those columns to the select statement 690 foreach($criteria->getGroupByColumns() as $column) 494 foreach($criteria->getGroupByColumns() as $column) 691 495 { 692 496 $criteria->addSelectColumn($column); … … 699 503 return $rs->getInt(1); 700 504 } else { 701 // no rows returned; we infer that means 0 matches. 702 return 0; 703 } 704 } 705 706 707 /** 708 * Returns the number of rows matching criteria, joining the related User table 709 * 710 * @param Criteria $c 711 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 712 * @param Connection $con 713 * @return int Number of matching rows. 714 */ 505 return 0; 506 } 507 } 508 509 510 715 511 public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null) 716 512 { 717 // we're going to modify criteria, so copy it first 718 $criteria = clone $criteria; 719 720 // clear out anything that might confuse the ORDER BY clause 721 $criteria->clearSelectColumns()->clearOrderByColumns(); 513 $criteria = clone $criteria; 514 515 $criteria->clearSelectColumns()->clearOrderByColumns(); 722 516 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 723 517 $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); … … 726 520 } 727 521 728 // just in case we're grouping: add those columns to the select statement 729 foreach($criteria->getGroupByColumns() as $column) 522 foreach($criteria->getGroupByColumns() as $column) 730 523 { 731 524 $criteria->addSelectColumn($column); … … 738 531 return $rs->getInt(1); 739 532 } else { 740 // no rows returned; we infer that means 0 matches. 741 return 0; 742 } 743 } 744 745 746 /** 747 * Selects a collection of Answer objects pre-filled with all related objects except Question. 748 * 749 * @return array Array of Answer objects. 750 * @throws PropelException Any exceptions caught during processing will be 751 * rethrown wrapped into a PropelException. 752 */ 533 return 0; 534 } 535 } 536 537 538 753 539 public static function doSelectJoinAllExceptQuestion(Criteria $c, $con = null) 754 540 { 755 541 $c = clone $c; 756 542 757 // Set the correct dbName if it has not been overridden 758 // $c->getDbName() will return the same object if not set to another value 759 // so == check is okay and faster 760 if ($c->getDbName() == Propel::getDefaultDB()) { 543 if ($c->getDbName() == Propel::getDefaultDB()) { 761 544 $c->setDbName(self::DATABASE_NAME); 762 545 } … … 792 575 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 793 576 $temp_obj1 = $results[$j]; 794 $temp_obj2 = $temp_obj1->getUser(); //CHECKME 795 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 577 $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 796 578 $newObject = false; 797 579 $temp_obj2->addAnswer($obj1); … … 811 593 812 594 813 /** 814 * Selects a collection of Answer objects pre-filled with all related objects except User. 815 * 816 * @return array Array of Answer objects. 817 * @throws PropelException Any exceptions caught during processing will be 818 * rethrown wrapped into a PropelException. 819 */ 595 820 596 public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) 821 597 { 822 598 $c = clone $c; 823 599 824 // Set the correct dbName if it has not been overridden 825 // $c->getDbName() will return the same object if not set to another value 826 // so == check is okay and faster 827 if ($c->getDbName() == Propel::getDefaultDB()) { 600 if ($c->getDbName() == Propel::getDefaultDB()) { 828 601 $c->setDbName(self::DATABASE_NAME); 829 602 } … … 859 632 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 860 633 $temp_obj1 = $results[$j]; 861 $temp_obj2 = $temp_obj1->getQuestion(); //CHECKME 862 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 634 $temp_obj2 = $temp_obj1->getQuestion(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 863 635 $newObject = false; 864 636 $temp_obj2->addAnswer($obj1); … … 877 649 } 878 650 879 /** 880 * Returns the TableMap related to this peer. 881 * This method is not needed for general use but a specific application could have a need. 882 * @return TableMap 883 * @throws PropelException Any exceptions caught during processing will be 884 * rethrown wrapped into a PropelException. 885 */ 651 886 652 public static function getTableMap() 887 653 { … … 889 655 } 890 656 891 /** 892 * The class that the Peer will make instances of. 893 * 894 * This uses a dot-path notation which is tranalted into a path 895 * relative to a location on the PHP include_path. 896 * (e.g. path.to.MyClass -> 'path/to/MyClass.php') 897 * 898 * @return string path.to.ClassName 899 */ 657 900 658 public static function getOMClass() 901 659 { … … 903 661 } 904 662 905 /** 906 * Method perform an INSERT on the database, given a Answer or Criteria object. 907 * 908 * @param mixed $values Criteria or Answer object containing data that is used to create the INSERT statement. 909 * @param Connection $con the connection to use 910 * @return mixed The new primary key. 911 * @throws PropelException Any exceptions caught during processing will be 912 * rethrown wrapped into a PropelException. 913 */ 663 914 664 public static function doInsert($values, $con = null) 915 665 { … … 919 669 920 670 if ($values instanceof Criteria) { 921 $criteria = clone $values; // rename for clarity 922 } else { 923 $criteria = $values->buildCriteria(); // build Criteria from Answer object 924 } 925 926 $criteria->remove(AnswerPeer::ID); // remove pkey col since this table uses auto-increment 927 928 929 // Set the correct dbName 930 $criteria->setDbName(self::DATABASE_NAME); 671 $criteria = clone $values; } else { 672 $criteria = $values->buildCriteria(); } 673 674 $criteria->remove(AnswerPeer::ID); 675 676 $criteria->setDbName(self::DATABASE_NAME); 931 677 932 678 try { 933 // use transaction because $criteria could contain info 934 // for more than one table (I guess, conceivably) 935 $con->begin(); 679 $con->begin(); 936 680 $pk = BasePeer::doInsert($criteria, $con); 937 681 $con->commit(); … … 944 688 } 945 689 946 /** 947 * Method perform an UPDATE on the database, given a Answer or Criteria object. 948 * 949 * @param mixed $values Criteria or Answer object containing data that is used to create the UPDATE statement. 950 * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). 951 * @return int The number of affected rows (if supported by underlying database driver). 952 * @throws PropelException Any exceptions caught during processing will be 953 * rethrown wrapped into a PropelException. 954 */ 690 955 691 public static function doUpdate($values, $con = null) 956 692 { … … 962 698 963 699 if ($values instanceof Criteria) { 964 $criteria = clone $values; // rename for clarity 965 700 $criteria = clone $values; 966 701 $comparison = $criteria->getComparison(AnswerPeer::ID); 967 702 $selectCriteria->add(AnswerPeer::ID, $criteria->remove(AnswerPeer::ID), $comparison); 968 703 969 } else { // $values is Answer object 970 $criteria = $values->buildCriteria(); // gets full criteria 971 $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) 972 } 973 974 // set the correct dbName 975 $criteria->setDbName(self::DATABASE_NAME); 704 } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } 705 706 $criteria->setDbName(self::DATABASE_NAME); 976 707 977 708 return BasePeer::doUpdate($selectCriteria, $criteria, $con); 978 709 } 979 710 980 /** 981 * Method to DELETE all rows from the ask_answer table. 982 * 983 * @return int The number of affected rows (if supported by underlying database driver). 984 */ 711 985 712 public static function doDeleteAll($con = null) 986 713 { … … 988 715 $con = Propel::getConnection(self::DATABASE_NAME); 989 716 } 990 $affectedRows = 0; // initialize var to track total num of affected rows 991 try { 992 // use transaction because $criteria could contain info 993 // for more than one table or we could emulating ON DELETE CASCADE, etc. 994 $con->begin(); 717 $affectedRows = 0; try { 718 $con->begin(); 995 719 $affectedRows += BasePeer::doDeleteAll(AnswerPeer::TABLE_NAME, $con); 996 720 $con->commit(); … … 1002 726 } 1003 727 1004 /** 1005 * Method perform a DELETE on the database, given a Answer or Criteria object OR a primary key value. 1006 * 1007 * @param mixed $values Criteria or Answer object or primary key or array of primary keys 1008 * which is used to create the DELETE statement 1009 * @param Connection $con the connection to use 1010 * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows 1011 * if supported by native driver or if emulated using Propel. 1012 * @throws PropelException Any exceptions caught during processing will be 1013 * rethrown wrapped into a PropelException. 1014 */ 728 1015 729 public static function doDelete($values, $con = null) 1016 730 { … … 1020 734 1021 735 if ($values instanceof Criteria) { 1022 $criteria = clone $values; // rename for clarity 1023 } elseif ($values instanceof Answer) { 736 $criteria = clone $values; } elseif ($values instanceof Answer) { 1024 737 1025 738 $criteria = $values->buildPkeyCriteria(); 1026 739 } else { 1027 // it must be the primary key 1028 $criteria = new Criteria(self::DATABASE_NAME); 740 $criteria = new Criteria(self::DATABASE_NAME); 1029 741 $criteria->add(AnswerPeer::ID, (array) $values, Criteria::IN); 1030 742 } 1031 743 1032 // Set the correct dbName 1033 $criteria->setDbName(self::DATABASE_NAME); 1034 1035 $affectedRows = 0; // initialize var to track total num of affected rows 1036 744 $criteria->setDbName(self::DATABASE_NAME); 745 746 $affectedRows = 0; 1037 747 try { 1038 // use transaction because $criteria could contain info 1039 // for more than one table or we could emulating ON DELETE CASCADE, etc. 1040 $con->begin(); 748 $con->begin(); 1041 749 1042 750 $affectedRows += BasePeer::doDelete($criteria, $con); … … 1049 757 } 1050 758 1051 /** 1052 * Validates all modified columns of given Answer object. 1053 * If parameter $columns is either a single column name or an array of column names 1054 * than only those columns are validated. 1055 * 1056 * NOTICE: This does not apply to primary or foreign keys for now. 1057 * 1058 * @param Answer $obj The object to validate. 1059 * @param mixed $cols Column name or array of column names. 1060 * 1061 * @return mixed TRUE if all columns are valid or the error message of the first invalid column. 1062 */ 759 1063 760 public static function doValidate(Answer $obj, $cols = null) 1064 761 { … … 1095 792 } 1096 793 1097 /** 1098 * Retrieve a single object by pkey. 1099 * 1100 * @param mixed $pk the primary key. 1101 * @param Connection $con the connection to use 1102 * @return Answer 1103 */ 794 1104 795 public static function retrieveByPK($pk, $con = null) 1105 796 { … … 1114 805 1115 806 $v = AnswerPeer::doSelect($criteria, $con); 1116 return !empty($v) > 0 ? $v[0] : null; 1117 } 1118 1119 /** 1120 * Retrieve multiple objects by pkey. 1121 * 1122 * @param array $pks List of primary keys 1123 * @param Connection $con the connection to use 1124 * @throws PropelException Any exceptions caught during processing will be 1125 * rethrown wrapped into a PropelException. 1126 */ 807 808 return !empty($v) > 0 ? $v[0] : null; 809 } 810 811 1127 812 public static function retrieveByPKs($pks, $con = null) 1128 813 { … … 1142 827 } 1143 828 1144 } // BaseAnswerPeer 1145 1146 // static code to register the map builder for this Peer with the main Propel class 829 } 1147 830 if (Propel::isInit()) { 1148 // the MapBuilder classes register themselves with Propel during initialization 1149 // so we need to load them here. 1150 try { 831 try { 1151 832 BaseAnswerPeer::getMapBuilder(); 1152 833 } catch (Exception $e) { … … 1154 835 } 1155 836 } else { 1156 // even if Propel is not yet initialized, the map builder class can be registered 1157 // now and then it will be loaded when Propel initializes. 1158 require_once 'model/map/AnswerMapBuilder.php'; 1159 Propel::registerMapBuilder('model.map.AnswerMapBuilder'); 837 require_once 'lib/model/map/AnswerMapBuilder.php'; 838 Propel::registerMapBuilder('lib.model.map.AnswerMapBuilder'); 1160 839 } trunk/lib/model/om/BaseInterest.php
r74 r88 1 1 <?php 2 2 3 require_once 'propel/om/BaseObject.php'; 4 5 require_once 'propel/om/Persistent.php'; 6 7 8 include_once 'propel/util/Criteria.php'; 9 10 include_once 'model/InterestPeer.php'; 11 12 /** 13 * Base class that represents a row from the 'ask_interest' table. 14 * 15 * 16 * 17 * @package model.om 18 */ 3 19 4 abstract class BaseInterest extends BaseObject implements Persistent { 20 5 21 6 22 /** 23 * The Peer class. 24 * Instance provides a convenient way of calling static methods on a class 25 * that calling code may not be able to identify. 26 * @var InterestPeer 27 */ 7 8 const DATABASE_NAME = 'symfony'; 9 10 28 11 protected static $peer; 29 12 30 13 31 /** 32 * The value for the question_id field. 33 * @var int 34 */ 14 35 15 protected $question_id; 36 16 37 17 38 /** 39 * The value for the user_id field. 40 * @var int 41 */ 18 42 19 protected $user_id; 43 20 44 21 45 /** 46 * The value for the created_at field. 47 * @var int 48 */ 22 49 23 protected $created_at; 50 24 51 /** 52 * @var Question 53 */ 25 54 26 protected $aQuestion; 55 27 56 /** 57 * @var User 58 */ 28 59 29 protected $aUser; 60 30 61 /** 62 * Flag to prevent endless save loop, if this object is referenced 63 * by another object which falls in this transaction. 64 * @var boolean 65 */ 31 66 32 protected $alreadyInSave = false; 67 33 68 /** 69 * Flag to prevent endless validation loop, if this object is referenced 70 * by another object which falls in this transaction. 71 * @var boolean 72 */ 34 73 35 protected $alreadyInValidation = false; 74 36 75 /** 76 * Get the [question_id] column value. 77 * 78 * @return int 79 */ 37 80 38 public function getQuestionId() 81 39 { … … 84 42 } 85 43 86 /** 87 * Get the [user_id] column value. 88 * 89 * @return int 90 */ 44 91 45 public function getUserId() 92 46 { … … 95 49 } 96 50 97 /** 98 * Get the [optionally formatted] [created_at] column value. 99 * 100 * @param string $format The date/time format string (either date()-style or strftime()-style). 101 * If format is NULL, then the integer unix timestamp will be returned. 102 * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). 103 * @throws PropelException - if unable to convert the date/time to timestamp. 104 */ 51 105 52 public function getCreatedAt($format = 'Y-m-d H:i:s') 106 53 { … … 109 56 return null; 110 57 } elseif (!is_int($this->created_at)) { 111 // a non-timestamp value was set externally, so we convert it 112 $ts = strtotime($this->created_at); 113 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 114 throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); 58 $ts = strtotime($this->created_at); 59 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); 115 60 } 116 61 } else { … … 126 71 } 127 72 128 /** 129 * Set the value of [question_id] column. 130 * 131 * @param int $v new value 132 * @return void 133 */ 73 134 74 public function setQuestionId($v) 135 75 { … … 142 82 if ($this->aQuestion !== null && $this->aQuestion->getId() !== $v) { 143 83 $this->aQuestion = null; 144 } 145 146 } // setQuestionId() 147 148 /** 149 * Set the value of [user_id] column. 150 * 151 * @param int $v new value 152 * @return void 153 */ 84 } 85 86 } 87 154 88 public function setUserId($v) 155 89 { … … 162 96 if ($this->aUser !== null && $this->aUser->getId() !== $v) { 163 97 $this->aUser = null; 164 } 165 166 } // setUserId() 167 168 /** 169 * Set the value of [created_at] column. 170 * 171 * @param int $v new value 172 * @return void 173 */ 98 } 99 100 } 101 174 102 public function setCreatedAt($v) 175 103 { … … 177 105 if ($v !== null && !is_int($v)) { 178 106 $ts = strtotime($v); 179 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 180 throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); 107 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); 181 108 } 182 109 } else { … … 188 115 } 189 116 190 } // setCreatedAt() 191 192 /** 193 * Hydrates (populates) the object variables with values from the database resultset. 194 * 195 * An offset (1-based "start column") is specified so that objects can be hydrated 196 * with a subset of the columns in the resultset rows. This is needed, for example, 197 * for results of JOIN queries where the resultset row includes columns from two or 198 * more tables. 199 * 200 * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. 201 * @param int $startcol 1-based offset column which indicates which restultset column to start with. 202 * @return int next starting column 203 * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. 204 */ 117 } 118 205 119 public function hydrate(ResultSet $rs, $startcol = 1) 206 120 { … … 217 131 $this->setNew(false); 218 132 219 // FIXME - using NUM_COLUMNS may be clearer. 220 return $startcol + 3; // 3 = InterestPeer::NUM_COLUMNS - InterestPeer::NUM_LAZY_LOAD_COLUMNS). 221 133 return $startcol + 3; 222 134 } catch (Exception $e) { 223 135 throw new PropelException("Error populating Interest object", $e); … … 225 137 } 226 138 227 /** 228 * Removes this object from datastore and sets delete attribute. 229 * 230 * @param Connection $con 231 * @return void 232 * @throws PropelException 233 * @see BaseObject::setDeleted() 234 * @see BaseObject::isDeleted() 235 */ 139 236 140 public function delete($con = null) 237 141 { … … 255 159 } 256 160 257 /** 258 * Stores the object in the database. If the object is new, 259 * it inserts it; otherwise an update is performed. This method 260 * wraps the doSave() worker method in a transaction. 261 * 262 * @param Connection $con 263 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. 264 * @throws PropelException 265 * @see doSave() 266 */ 161 267 162 public function save($con = null) 268 163 { 269 if ($this->isNew() )164 if ($this->isNew() && !$this->isColumnModified(InterestPeer::CREATED_AT)) 270 165 { 271 166 $this->setCreatedAt(time()); … … 279 174 $con = Propel::getConnection(InterestPeer::DATABASE_NAME); 280 175 } 281 176 282 177 try { 283 178 $con->begin(); … … 291 186 } 292 187 293 /** 294 * Stores the object in the database. 295 * 296 * If the object is new, it inserts it; otherwise an update is performed. 297 * All related objects are also updated in this method. 298 * 299 * @param Connection $con 300 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. 301 * @throws PropelException 302 * @see save() 303 */ 188 304 189 protected function doSave($con) 305 190 { 306 $affectedRows = 0; // initialize var to track total num of affected rows 307 if (!$this->alreadyInSave) { 191 $affectedRows = 0; if (!$this->alreadyInSave) { 308 192 $this->alreadyInSave = true; 309 193 310 194 311 // We call the save method on the following object(s) if they 312 // were passed to this object by their coresponding set 313 // method. This object relates to these object(s) by a 314 // foreign key reference. 315 195 316 196 if ($this->aQuestion !== null) { 317 197 if ($this->aQuestion->isModified()) { … … 327 207 $this->setUser($this->aUser); 328 208 } 329 330 331 // If this object has been modified, then save it to the database. 332 if ($this->isModified()) { 209 210 211 if ($this->isModified()) { 333 212 if ($this->isNew()) { 334 213 $pk = InterestPeer::doInsert($this, $con); 335 $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which 336 // should always be true here (even though technically 337 // BasePeer::doInsert() can insert multiple rows). 338 214 $affectedRows += 1; 339 215 $this->setNew(false); 340 216 } else { 341 217 $affectedRows += InterestPeer::doUpdate($this, $con); 342 218 } 343 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 344 } 219 $this->resetModified(); } 345 220 346 221 $this->alreadyInSave = false; 347 222 } 348 223 return $affectedRows; 349 } // doSave() 350 351 /** 352 * Array of ValidationFailed objects. 353 * @var array ValidationFailed[] 354 */ 224 } 225 355 226 protected $validationFailures = array(); 356 227 357 /** 358 * Gets any ValidationFailed objects that resulted from last call to validate(). 359 * 360 * 361 * @return array ValidationFailed[] 362 * @see validate() 363 */ 228 364 229 public function getValidationFailures() 365 230 { … … 367 232 } 368 233 369 /** 370 * Validates the objects modified field values and all objects related to this table. 371 * 372 * If $columns is either a column name or an array of column names 373 * only those columns are validated. 374 * 375 * @param mixed $columns Column name or an array of column names. 376 * @return boolean Whether all columns pass validation. 377 * @see doValidate() 378 * @see getValidationFailures() 379 */ 234 380 235 public function validate($columns = null) 381 236 { … … 390 245 } 391 246 392 /** 393 * This function performs the validation work for complex object models. 394 * 395 * In addition to checking the current object, all related objects will 396 * also be validated. If all pass then <code>true</code> is returned; otherwise 397 * an aggreagated array of ValidationFailed objects will be returned. 398 * 399 * @param array $columns Array of column names to validate. 400 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 401 */ 247 402 248 protected function doValidate($columns = null) 403 249 { … … 409 255 410 256 411 // We call the validate method on the following object(s) if they 412 // were passed to this object by their coresponding set 413 // method. This object relates to these object(s) by a 414 // foreign key reference. 415 257 416 258 if ($this->aQuestion !== null) { 417 259 if (!$this->aQuestion->validate($columns)) { … … 439 281 } 440 282 441 /** 442 * Retrieves a field from the object by name passed in as a string. 443 * 444 * @param string $name name 445 * @param string $type The type of fieldname the $name is of: 446 * one of the class type constants TYPE_PHPNAME, 447 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 448 * @return mixed Value of field. 449 */ 283 450 284 public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 451 285 { … … 454 288 } 455 289 456 /** 457 * Retrieves a field from the object by Position as specified in the xml schema. 458 * Zero-based. 459 * 460 * @param int $pos position in xml schema 461 * @return mixed Value of field at $pos 462 */ 290 463 291 public function getByPosition($pos) 464 292 { … … 476 304 return null; 477 305 break; 478 } // switch() 479 } 480 481 /** 482 * Exports the object as an array. 483 * 484 * You can specify the key type of the array by passing one of the class 485 * type constants. 486 * 487 * @param string $keyType One of the class type constants TYPE_PHPNAME, 488 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 489 * @return an associative array containing the field names (as keys) and field values 490 */ 306 } } 307 308 491 309 public function toArray($keyType = BasePeer::TYPE_PHPNAME) 492 310 { … … 500 318 } 501 319 502 /** 503 * Sets a field from the object by name passed in as a string. 504 * 505 * @param string $name peer name 506 * @param mixed $value field value 507 * @param string $type The type of fieldname the $name is of: 508 * one of the class type constants TYPE_PHPNAME, 509 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 510 * @return void 511 */ 320 512 321 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 513 322 { … … 516 325 } 517 326 518 /** 519 * Sets a field from the object by Position as specified in the xml schema. 520 * Zero-based. 521 * 522 * @param int $pos position in xml schema 523 * @param mixed $value field value 524 * @return void 525 */ 327 526 328 public function setByPosition($pos, $value) 527 329 { … … 536 338 $this->setCreatedAt($value); 537 339 break; 538 } // switch() 539 } 540 541 /** 542 * Populates the object using an array. 543 * 544 * This is particularly useful when populating an object from one of the 545 * request arrays (e.g. $_POST). This method goes through the column 546 * names, checking to see whether a matching key exists in populated 547 * array. If so the setByName() method is called for that column. 548 * 549 * You can specify the key type of the array by additionally passing one 550 * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, 551 * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') 552 * 553 * @param array $arr An array to populate the object from. 554 * @param string $keyType The type of keys the array uses. 555 * @return void 556 */ 340 } } 341 342 557 343 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) 558 344 { … … 564 350 } 565 351 566 /** 567 * Build a Criteria object containing the values of all modified columns in this object. 568 * 569 * @return Criteria The Criteria object containing all modified values. 570 */ 352 571 353 public function buildCriteria() 572 354 { … … 580 362 } 581 363 582 /** 583 * Builds a Criteria object containing the primary key for this object. 584 * 585 * Unlike buildCriteria() this method includes the primary key values regardless 586 * of whether or not they have been modified. 587 * 588 * @return Criteria The Criteria object containing value(s) for primary key(s). 589 */ 364 590 365 public function buildPkeyCriteria() 591 366 { … … 598 373 } 599 374 600 /** 601 * Returns the composite primary key for this object. 602 * The array elements will be in same order as specified in XML. 603 * @return array 604 */ 375 605 376 public function getPrimaryKey() 606 377 { … … 614 385 } 615 386 616 /** 617 * Set the [composite] primary key. 618 * 619 * @param array $keys The elements of the composite key (order must match the order in XML file). 620 * @return void 621 */ 387 622 388 public function setPrimaryKey($keys) 623 389 { … … 629 395 } 630 396 631 /** 632 * Sets contents of passed object to values from current object. 633 * 634 * If desired, this method can also make copies of all associated (fkey referrers) 635 * objects. 636 * 637 * @param object $copyObj An object of Interest (or compatible) type. 638 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 639 * @throws PropelException 640 */ 397 641 398 public function copyInto($copyObj, $deepCopy = false) 642 399 { … … 647 404 $copyObj->setNew(true); 648 405 649 $copyObj->setQuestionId(NULL); // this is a pkey column, so set to default value 650 651 $copyObj->setUserId(NULL); // this is a pkey column, so set to default value 652 653 } 654 655 /** 656 * Makes a copy of this object that will be inserted as a new row in table when saved. 657 * It creates a new object filling in the simple attributes, but skipping any primary 658 * keys that are defined for the table. 659 * 660 * If desired, this method can also make copies of all associated (fkey referrers) 661 * objects. 662 * 663 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 664 * @return Interest Clone of current object. 665 * @throws PropelException 666 */ 406 $copyObj->setQuestionId(NULL); 407 $copyObj->setUserId(NULL); 408 } 409 410 667 411 public function copy($deepCopy = false) 668 412 { 669 // we use get_class(), because this might be a subclass 670 $clazz = get_class($this); 413 $clazz = get_class($this); 671 414 $copyObj = new $clazz(); 672 415 $this->copyInto($copyObj, $deepCopy); … … 674 417 } 675 418 676 /** 677 * Returns a peer instance associated with this om. 678 * 679 * Since Peer classes are not to have any instance attributes, this method returns the 680 * same instance for all member of this class. The method could therefore 681 * be static, but this would prevent one from overriding the behavior. 682 * 683 * @return InterestPeer 684 */ 419 685 420 public function getPeer() 686 421 { … … 691 426 } 692 427 693 /** 694 * Declares an association between this object and a Question object. 695 * 696 * @param Question $v 697 * @return void 698 * @throws PropelException 699 */ 428 700 429 public function setQuestion($v) 701 430 { … … 713 442 714 443 715 /** 716 * Get the associated Question object 717 * 718 * @param Connection Optional Connection object. 719 * @return Question The associated Question object. 720 * @throws PropelException 721 */ 444 722 445 public function getQuestion($con = null) 723 446 { 724 // include the related Peer class 725 include_once 'model/om/BaseQuestionPeer.php'; 447 include_once 'lib/model/om/BaseQuestionPeer.php'; 726 448 727 449 if ($this->aQuestion === null && ($this->question_id !== null)) { 728 450 729 451 $this->aQuestion = QuestionPeer::retrieveByPK($this->question_id, $con); 730 731 /* The following can be used instead of the line above to 732 guarantee the related object contains a reference 733 to this object, but this level of coupling 734 may be undesirable in many circumstances. 735 As it can lead to a db query with many results that may 736 never be used. 737 $obj = QuestionPeer::retrieveByPK($this->question_id, $con); 738 $obj->addQuestions($this); 739 */ 452 453 740 454 } 741 455 return $this->aQuestion; 742 456 } 743 457 744 /** 745 * Declares an association between this object and a User object. 746 * 747 * @param User $v 748 * @return void 749 * @throws PropelException 750 */ 458 751 459 public function setUser($v) 752 460 { … … 764 472 765 473 766 /** 767 * Get the associated User object 768 * 769 * @param Connection Optional Connection object. 770 * @return User The associated User object. 771 * @throws PropelException 772 */ 474 773 475 public function getUser($con = null) 774 476 { 775 // include the related Peer class 776 include_once 'model/om/BaseUserPeer.php'; 477 include_once 'lib/model/om/BaseUserPeer.php'; 777 478 778 479 if ($this->aUser === null && ($this->user_id !== null)) { 779 480 780 481 $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); 781 782 /* The following can be used instead of the line above to 783 guarantee the related object contains a reference 784 to this object, but this level of coupling 785 may be undesirable in many circumstances. 786 As it can lead to a db query with many results that may 787 never be used. 788 $obj = UserPeer::retrieveByPK($this->user_id, $con); 789 $obj->addUsers($this); 790 */ 482 483 791 484 } 792 485 return $this->aUser; 793 486 } 794 487 795 } // BaseInterest488 } trunk/lib/model/om/BaseInterestPeer.php
r74 r88 1 1 <?php 2 2 3 require_once 'propel/util/BasePeer.php'; 4 // The object class -- needed for instanceof checks in this class. 5 // actual class may be a subclass -- as returned by InterestPeer::getOMClass() 6 include_once 'model/Interest.php'; 7 8 /** 9 * Base static class for performing query and update operations on the 'ask_interest' table. 10 * 11 * 12 * 13 * @package model.om 14 */ 3 15 4 abstract class BaseInterestPeer { 16 5 17 /** the default database name for this class */6 18 7 const DATABASE_NAME = 'symfony'; 19 8 20 /** the table name for this class */9 21 10 const TABLE_NAME = 'ask_interest'; 22 11 23 /** A class that can be returned by this peer. */24 const CLASS_DEFAULT = ' model.Interest';25 26 /** The total number of columns. */12 13 const CLASS_DEFAULT = 'lib.model.Interest'; 14 15 27 16 const NUM_COLUMNS = 3; 28 17 29 /** The number of lazy-loaded columns. */18 30 19 const NUM_LAZY_LOAD_COLUMNS = 0; 31 20 32 21 33 /** the column name for the QUESTION_ID field */22 34 23 const QUESTION_ID = 'ask_interest.QUESTION_ID'; 35 24 36 /** the column name for the USER_ID field */25 37 26 const USER_ID = 'ask_interest.USER_ID'; 38 27 39 /** the column name for the CREATED_AT field */28 40 29 const CREATED_AT = 'ask_interest.CREATED_AT'; 41 30 42 /** The PHP to DB Name Mapping */31 43 32 private static $phpNameMap = null; 44 33 45 34 46 /** 47 * holds an array of fieldnames 48 * 49 * first dimension keys are the type constants 50 * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' 51 */ 35 52 36 private static $fieldNames = array ( 53 37 BasePeer::TYPE_PHPNAME => array ('QuestionId', 'UserId', 'CreatedAt', ), … … 57 41 ); 58 42 59 /** 60 * holds an array of keys for quick access to the fieldnames array 61 * 62 * first dimension keys are the type constants 63 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 64 */ 43 65 44 private static $fieldKeys = array ( 66 45 BasePeer::TYPE_PHPNAME => array ('QuestionId' => 0, 'UserId' => 1, 'CreatedAt' => 2, ), … … 70 49 ); 71 50 72 /** 73 * @return MapBuilder the map builder for this peer 74 * @throws PropelException Any exceptions caught during processing will be 75 * rethrown wrapped into a PropelException. 76 */ 51 77 52 public static function getMapBuilder() 78 53 { 79 include_once 'model/map/InterestMapBuilder.php'; 80 return BasePeer::getMapBuilder('model.map.InterestMapBuilder'); 81 } 82 /** 83 * Gets a map (hash) of PHP names to DB column names. 84 * 85 * @return array The PHP to DB name map for this peer 86 * @throws PropelException Any exceptions caught during processing will be 87 * rethrown wrapped into a PropelException. 88 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. 89 */ 54 include_once 'lib/model/map/InterestMapBuilder.php'; 55 return BasePeer::getMapBuilder('lib.model.map.InterestMapBuilder'); 56 } 57 90 58 public static function getPhpNameMap() 91 59 { … … 101 69 return self::$phpNameMap; 102 70 } 103 /** 104 * Translates a fieldname to another type 105 * 106 * @param string $name field name 107 * @param string $fromType One of the class type constants TYPE_PHPNAME, 108 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 109 * @param string $toType One of the class type constants 110 * @return string translated name of the field. 111 */ 71 112 72 static public function translateFieldName($name, $fromType, $toType) 113 73 { … … 120 80 } 121 81 122 /** 123 * Returns an array of of field names. 124 * 125 * @param string $type The type of fieldnames to return: 126 * One of the class type constants TYPE_PHPNAME, 127 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 128 * @return array A list of field names 129 */ 82 130 83 131 84 static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) … … 137 90 } 138 91 139 /** 140 * Convenience method which changes table.column to alias.column. 141 * 142 * Using this method you can maintain SQL abstraction while using column aliases. 143 * <code> 144 * $c->addAlias("alias1", TablePeer::TABLE_NAME); 145 * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); 146 * </code> 147 * @param string $alias The alias for the current table. 148 * @param string $column The column name for current table. (i.e. InterestPeer::COLUMN_NAME). 149 * @return string 150 */ 92 151 93 public static function alias($alias, $column) 152 94 { … … 154 96 } 155 97 156 /** 157 * Add all the columns needed to create a new object. 158 * 159 * Note: any columns that were marked with lazyLoad="true" in the 160 * XML schema will not be added to the select list and only loaded 161 * on demand. 162 * 163 * @param criteria object containing the columns to add. 164 * @throws PropelException Any exceptions caught during processing will be 165 * rethrown wrapped into a PropelException. 166 */ 98 167 99 public static function addSelectColumns(Criteria $criteria) 168 100 { … … 179 111 const COUNT_DISTINCT = 'COUNT(DISTINCT ask_interest.QUESTION_ID)'; 180 112 181 /** 182 * Returns the number of rows matching criteria. 183 * 184 * @param Criteria $criteria 185 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 186 * @param Connection $con 187 * @return int Number of matching rows. 188 */ 113 189 114 public static function doCount(Criteria $criteria, $distinct = false, $con = null) 190 115 { 191 // we're going to modify criteria, so copy it first 192 $criteria = clone $criteria; 193 194 // clear out anything that might confuse the ORDER BY clause 195 $criteria->clearSelectColumns()->clearOrderByColumns(); 116 $criteria = clone $criteria; 117 118 $criteria->clearSelectColumns()->clearOrderByColumns(); 196 119 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 197 120 $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); … … 200 123 } 201 124 202 // just in case we're grouping: add those columns to the select statement 203 foreach($criteria->getGroupByColumns() as $column) 125 foreach($criteria->getGroupByColumns() as $column) 204 126 { 205 127 $criteria->addSelectColumn($column); … … 210 132 return $rs->getInt(1); 211 133 } else { 212 // no rows returned; we infer that means 0 matches. 213 return 0; 214 } 215 } 216 /** 217 * Method to select one object from the DB. 218 * 219 * @param Criteria $criteria object used to create the SELECT statement. 220 * @param Connection $con 221 * @return Interest 222 * @throws PropelException Any exceptions caught during processing will be 223 * rethrown wrapped into a PropelException. 224 */ 134 return 0; 135 } 136 } 137 225 138 public static function doSelectOne(Criteria $criteria, $con = null) 226 139 { … … 233 146 return null; 234 147 } 235 /** 236 * Method to do selects. 237 * 238 * @param Criteria $criteria The Criteria object used to build the SELECT statement. 239 * @param Connection $con 240 * @return array Array of selected Objects 241 * @throws PropelException Any exceptions caught during processing will be 242 * rethrown wrapped into a PropelException. 243 */ 148 244 149 public static function doSelect(Criteria $criteria, $con = null) 245 150 { 246 151 return InterestPeer::populateObjects(InterestPeer::doSelectRS($criteria, $con)); 247 152 } 248 /** 249 * Prepares the Criteria object and uses the parent doSelect() 250 * method to get a ResultSet. 251 * 252 * Use this method directly if you want to just get the resultset 253 * (instead of an array of objects). 254 * 255 * @param Criteria $criteria The Criteria object used to build the SELECT statement. 256 * @param Connection $con the connection to use 257 * @throws PropelException Any exceptions caught during processing will be 258 * rethrown wrapped into a PropelException. 259 * @return ResultSet The resultset object with numerically-indexed fields. 260 * @see BasePeer::doSelect() 261 */ 153 262 154 public static function doSelectRS(Criteria $criteria, $con = null) 263 155 { … … 271 163 } 272 164 273 // Set the correct dbName 274 $criteria->setDbName(self::DATABASE_NAME); 275 276 // BasePeer returns a Creole ResultSet, set to return 277 // rows indexed numerically. 278 return BasePeer::doSelect($criteria, $con); 279 } 280 /** 281 * The returned array will contain objects of the default type or 282 * objects that inherit from the default. 283 * 284 * @throws PropelException Any exceptions caught during processing will be 285 * rethrown wrapped into a PropelException. 286 */ 165 $criteria->setDbName(self::DATABASE_NAME); 166 167 return BasePeer::doSelect($criteria, $con); 168 } 169 287 170 public static function populateObjects(ResultSet $rs) 288 171 { 289 172 $results = array(); 290 173 291 // set the class once to avoid overhead in the loop 292 $cls = InterestPeer::getOMClass(); 174 $cls = InterestPeer::getOMClass(); 293 175 $cls = Propel::import($cls); 294 // populate the object(s) 295 while($rs->next()) { 176 while($rs->next()) { 296 177 297 178 $obj = new $cls(); … … 303 184 } 304 185 305 /** 306 * Returns the number of rows matching criteria, joining the related Question table 307 * 308 * @param Criteria $c 309 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 310 * @param Connection $con 311 * @return int Number of matching rows. 312 */ 186 313 187 public static function doCountJoinQuestion(Criteria $criteria, $distinct = false, $con = null) 314 188 { 315 // we're going to modify criteria, so copy it first 316 $criteria = clone $criteria; 317 318 // clear out anything that might confuse the ORDER BY clause 319 $criteria->clearSelectColumns()->clearOrderByColumns(); 189 $criteria = clone $criteria; 190 191 $criteria->clearSelectColumns()->clearOrderByColumns(); 320 192 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 321 193 $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); … … 324 196 } 325 197 326 // just in case we're grouping: add those columns to the select statement 327 foreach($criteria->getGroupByColumns() as $column) 198 foreach($criteria->getGroupByColumns() as $column) 328 199 { 329 200 $criteria->addSelectColumn($column); … … 336 207 return $rs->getInt(1); 337 208 } else { 338 // no rows returned; we infer that means 0 matches. 339 return 0; 340 } 341 } 342 343 344 /** 345 * Returns the number of rows matching criteria, joining the related User table 346 * 347 * @param Criteria $c 348 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 349 * @param Connection $con 350 * @return int Number of matching rows. 351 */ 209 return 0; 210 } 211 } 212 213 214 352 215 public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) 353 216 { 354 // we're going to modify criteria, so copy it first 355 $criteria = clone $criteria; 356 357 // clear out anything that might confuse the ORDER BY clause 358 $criteria->clearSelectColumns()->clearOrderByColumns(); 217 $criteria = clone $criteria; 218 219 $criteria->clearSelectColumns()->clearOrderByColumns(); 359 220 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 360 221 $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); … … 363 224 } 364 225 365 // just in case we're grouping: add those columns to the select statement 366 foreach($criteria->getGroupByColumns() as $column) 226 foreach($criteria->getGroupByColumns() as $column) 367 227 { 368 228 $criteria->addSelectColumn($column); … … 375 235 return $rs->getInt(1); 376 236 } else { 377 // no rows returned; we infer that means 0 matches. 378 return 0; 379 } 380 } 381 382 383 /** 384 * Selects a collection of Interest objects pre-filled with their Question objects. 385 * 386 * @return array Array of Interest objects. 387 * @throws PropelException Any exceptions caught during processing will be 388 * rethrown wrapped into a PropelException. 389 */ 237 return 0; 238 } 239 } 240 241 242 390 243 public static function doSelectJoinQuestion(Criteria $c, $con = null) 391 244 { 392 245 $c = clone $c; 393 246 394 // Set the correct dbName if it has not been overridden 395 if ($c->getDbName() == Propel::getDefaultDB()) { 247 if ($c->getDbName() == Propel::getDefaultDB()) { 396 248 $c->setDbName(self::DATABASE_NAME); 397 249 } … … 421 273 $newObject = true; 422 274 foreach($results as $temp_obj1) { 423 $temp_obj2 = $temp_obj1->getQuestion(); //CHECKME 424 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 275 $temp_obj2 = $temp_obj1->getQuestion(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 425 276 $newObject = false; 426 // e.g. $author->addBookRelatedByBookId() 427 $temp_obj2->addInterest($obj1); //CHECKME 428 break; 277 $temp_obj2->addInterest($obj1); break; 429 278 } 430 279 } 431 280 if ($newObject) { 432 281 $obj2->initInterests(); 433 $obj2->addInterest($obj1); //CHECKME 434 } 282 $obj2->addInterest($obj1); } 435 283 $results[] = $obj1; 436 284 } … … 439 287 440 288 441 /** 442 * Selects a collection of Interest objects pre-filled with their User objects. 443 * 444 * @return array Array of Interest objects. 445 * @throws PropelException Any exceptions caught during processing will be 446 * rethrown wrapped into a PropelException. 447 */ 289 448 290 public static function doSelectJoinUser(Criteria $c, $con = null) 449 291 { 450 292 $c = clone $c; 451 293 452 // Set the correct dbName if it has not been overridden 453 if ($c->getDbName() == Propel::getDefaultDB()) { 294 if ($c->getDbName() == Propel::getDefaultDB()) { 454 295 $c->setDbName(self::DATABASE_NAME); 455 296 } … … 479 320 $newObject = true; 480 321 foreach($results as $temp_obj1) { 481 $temp_obj2 = $temp_obj1->getUser(); //CHECKME 482 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 322 $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 483 323 $newObject = false; 484 // e.g. $author->addBookRelatedByBookId() 485 $temp_obj2->addInterest($obj1); //CHECKME 486 break; 324 $temp_obj2->addInterest($obj1); break; 487 325 } 488 326 } 489 327 if ($newObject) { 490 328 $obj2->initInterests(); 491 $obj2->addInterest($obj1); //CHECKME 492 } 329 $obj2->addInterest($obj1); } 493 330 $results[] = $obj1; 494 331 } … … 497 334 498 335 499 /** 500 * Returns the number of rows matching criteria, joining all related tables 501 * 502 * @param Criteria $c 503 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 504 * @param Connection $con 505 * @return int Number of matching rows. 506 */ 336 507 337 public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) 508 338 { 509 339 $criteria = clone $criteria; 510 340 511 // clear out anything that might confuse the ORDER BY clause 512 $criteria->clearSelectColumns()->clearOrderByColumns(); 341 $criteria->clearSelectColumns()->clearOrderByColumns(); 513 342 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 514 343 $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); … … 517 346 } 518 347 519 // just in case we're grouping: add those columns to the select statement 520 foreach($criteria->getGroupByColumns() as $column) 348 foreach($criteria->getGroupByColumns() as $column) 521 349 { 522 350 $criteria->addSelectColumn($column); … … 531 359 return $rs->getInt(1); 532 360 } else { 533 // no rows returned; we infer that means 0 matches. 534 return 0; 535 } 536 } 537 538 539 /** 540 * Selects a collection of Interest objects pre-filled with all related objects. 541 * 542 * @return array Array of Interest objects. 543 * @throws PropelException Any exceptions caught during processing will be 544 * rethrown wrapped into a PropelException. 545 */ 361 return 0; 362 } 363 } 364 365 366 546 367 public static function doSelectJoinAll(Criteria $c, $con = null) 547 368 { 548 369 $c = clone $c; 549 370 550 // Set the correct dbName if it has not been overridden 551 if ($c->getDbName() == Propel::getDefaultDB()) { 371 if ($c->getDbName() == Propel::getDefaultDB()) { 552 372 $c->setDbName(self::DATABASE_NAME); 553 373 } … … 579 399 580 400 581 // Add objects for joined Question rows 582 401 583 402 $omClass = QuestionPeer::getOMClass(); 584 403 … … 591 410 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 592 411 $temp_obj1 = $results[$j]; 593 $temp_obj2 = $temp_obj1->getQuestion(); // CHECKME 594 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 412 $temp_obj2 = $temp_obj1->getQuestion(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 595 413 $newObject = false; 596 $temp_obj2->addInterest($obj1); // CHECKME 597 break; 414 $temp_obj2->addInterest($obj1); break; 598 415 } 599 416 } … … 605 422 606 423 607 // Add objects for joined User rows 608 424 609 425 $omClass = UserPeer::getOMClass(); 610 426 … … 617 433 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 618 434 $temp_obj1 = $results[$j]; 619 $temp_obj3 = $temp_obj1->getUser(); // CHECKME 620 if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { 435 $temp_obj3 = $temp_obj1->getUser(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { 621 436 $newObject = false; 622 $temp_obj3->addInterest($obj1); // CHECKME 623 break; 437 $temp_obj3->addInterest($obj1); break; 624 438 } 625 439 } … … 636 450 637 451 638 /** 639 * Returns the number of rows matching criteria, joining the related Question table 640 * 641 * @param Criteria $c 642 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 643 * @param Connection $con 644 * @return int Number of matching rows. 645 */ 452 646 453 public static function doCountJoinAllExceptQuestion(Criteria $criteria, $distinct = false, $con = null) 647 454 { 648 // we're going to modify criteria, so copy it first 649 $criteria = clone $criteria; 650 651 // clear out anything that might confuse the ORDER BY clause 652 $criteria->clearSelectColumns()->clearOrderByColumns(); 455 $criteria = clone $criteria; 456 457 $criteria->clearSelectColumns()->clearOrderByColumns(); 653 458 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 654 459 $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); … … 657 462 } 658 463 659 // just in case we're grouping: add those columns to the select statement 660 foreach($criteria->getGroupByColumns() as $column) 464 foreach($criteria->getGroupByColumns() as $column) 661 465 { 662 466 $criteria->addSelectColumn($column); … … 669 473 return $rs->getInt(1); 670 474 } else { 671 // no rows returned; we infer that means 0 matches. 672 return 0; 673 } 674 } 675 676 677 /** 678 * Returns the number of rows matching criteria, joining the related User table 679 * 680 * @param Criteria $c 681 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 682 * @param Connection $con 683 * @return int Number of matching rows. 684 */ 475 return 0; 476 } 477 } 478 479 480 685 481 public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null) 686 482 { 687 // we're going to modify criteria, so copy it first 688 $criteria = clone $criteria; 689 690 // clear out anything that might confuse the ORDER BY clause 691 $criteria->clearSelectColumns()->clearOrderByColumns(); 483 $criteria = clone $criteria; 484 485 $criteria->clearSelectColumns()->clearOrderByColumns(); 692 486 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 693 487 $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); … … 696 490 } 697 491 698 // just in case we're grouping: add those columns to the select statement 699 foreach($criteria->getGroupByColumns() as $column) 492 foreach($criteria->getGroupByColumns() as $column) 700 493 { 701 494 $criteria->addSelectColumn($column); … … 708 501 return $rs->getInt(1); 709 502 } else { 710 // no rows returned; we infer that means 0 matches. 711 return 0; 712 } 713 } 714 715 716 /** 717 * Selects a collection of Interest objects pre-filled with all related objects except Question. 718 * 719 * @return array Array of Interest objects. 720 * @throws PropelException Any exceptions caught during processing will be 721 * rethrown wrapped into a PropelException. 722 */ 503 return 0; 504 } 505 } 506 507 508 723 509 public static function doSelectJoinAllExceptQuestion(Criteria $c, $con = null) 724 510 { 725 511 $c = clone $c; 726 512 727 // Set the correct dbName if it has not been overridden 728 // $c->getDbName() will return the same object if not set to another value 729 // so == check is okay and faster 730 if ($c->getDbName() == Propel::getDefaultDB()) { 513 if ($c->getDbName() == Propel::getDefaultDB()) { 731 514 $c->setDbName(self::DATABASE_NAME); 732 515 } … … 762 545 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 763 546 $temp_obj1 = $results[$j]; 764 $temp_obj2 = $temp_obj1->getUser(); //CHECKME 765 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 547 $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 766 548 $newObject = false; 767 549 $temp_obj2->addInterest($obj1); … … 781 563 782 564 783 /** 784 * Selects a collection of Interest objects pre-filled with all related objects except User. 785 * 786 * @return array Array of Interest objects. 787 * @throws PropelException Any exceptions caught during processing will be 788 * rethrown wrapped into a PropelException. 789 */ 565 790 566 public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) 791 567 { 792 568 $c = clone $c; 793 569 794 // Set the correct dbName if it has not been overridden 795 // $c->getDbName() will return the same object if not set to another value 796 // so == check is okay and faster 797 if ($c->getDbName() == Propel::getDefaultDB()) { 570 if ($c->getDbName() == Propel::getDefaultDB()) { 798 571 $c->setDbName(self::DATABASE_NAME); 799 572 } … … 829 602 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 830 603 $temp_obj1 = $results[$j]; 831 $temp_obj2 = $temp_obj1->getQuestion(); //CHECKME 832 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 604 $temp_obj2 = $temp_obj1->getQuestion(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 833 605 $newObject = false; 834 606 $temp_obj2->addInterest($obj1); … … 847 619 } 848 620 849 /** 850 * Returns the TableMap related to this peer. 851 * This method is not needed for general use but a specific application could have a need. 852 * @return TableMap 853 * @throws PropelException Any exceptions caught during processing will be 854 * rethrown wrapped into a PropelException. 855 */ 621 856 622 public static function getTableMap() 857 623 { … … 859 625 } 860 626 861 /** 862 * The class that the Peer will make instances of. 863 * 864 * This uses a dot-path notation which is tranalted into a path 865 * relative to a location on the PHP include_path. 866 * (e.g. path.to.MyClass -> 'path/to/MyClass.php') 867 * 868 * @return string path.to.ClassName 869 */ 627 870 628 public static function getOMClass() 871 629 { … … 873 631 } 874 632 875 /** 876 * Method perform an INSERT on the database, given a Interest or Criteria object. 877 * 878 * @param mixed $values Criteria or Interest object containing data that is used to create the INSERT statement. 879 * @param Connection $con the connection to use 880 * @return mixed The new primary key. 881 * @throws PropelException Any exceptions caught during processing will be 882 * rethrown wrapped into a PropelException. 883 */ 633 884 634 public static function doInsert($values, $con = null) 885 635 { … … 889 639 890 640 if ($values instanceof Criteria) { 891 $criteria = clone $values; // rename for clarity 892 } else { 893 $criteria = $values->buildCriteria(); // build Criteria from Interest object 894 } 895 896 897 // Set the correct dbName 898 $criteria->setDbName(self::DATABASE_NAME); 641 $criteria = clone $values; } else { 642 $criteria = $values->buildCriteria(); } 643 644 645 $criteria->setDbName(self::DATABASE_NAME); 899 646 900 647 try { 901 // use transaction because $criteria could contain info 902 // for more than one table (I guess, conceivably) 903 $con->begin(); 648 $con->begin(); 904 649 $pk = BasePeer::doInsert($criteria, $con); 905 650 $con->commit(); … … 912 657 } 913 658 914 /** 915 * Method perform an UPDATE on the database, given a Interest or Criteria object. 916 * 917 * @param mixed $values Criteria or Interest object containing data that is used to create the UPDATE statement. 918 * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). 919 * @return int The number of affected rows (if supported by underlying database driver). 920 * @throws PropelException Any exceptions caught during processing will be 921 * rethrown wrapped into a PropelException. 922 */ 659 923 660 public static function doUpdate($values, $con = null) 924 661 { … … 930 667 931 668 if ($values instanceof Criteria) { 932 $criteria = clone $values; // rename for clarity 933 669 $criteria = clone $values; 934 670 $comparison = $criteria->getComparison(InterestPeer::QUESTION_ID); 935 671 $selectCriteria->add(InterestPeer::QUESTION_ID, $criteria->remove(InterestPeer::QUESTION_ID), $comparison); … … 938 674 $selectCriteria->add(InterestPeer::USER_ID, $criteria->remove(InterestPeer::USER_ID), $comparison); 939 675 940 } else { // $values is Interest object 941 $criteria = $values->buildCriteria(); // gets full criteria 942 $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) 943 } 944 945 // set the correct dbName 946 $criteria->setDbName(self::DATABASE_NAME); 676 } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } 677 678 $criteria->setDbName(self::DATABASE_NAME); 947 679 948 680 return BasePeer::doUpdate($selectCriteria, $criteria, $con); 949 681 } 950 682 951 /** 952 * Method to DELETE all rows from the ask_interest table. 953 * 954 * @return int The number of affected rows (if supported by underlying database driver). 955 */ 683 956 684 public static function doDeleteAll($con = null) 957 685 { … … 959 687 $con = Propel::getConnection(self::DATABASE_NAME); 960 688 } 961 $affectedRows = 0; // initialize var to track total num of affected rows 962 try { 963 // use transaction because $criteria could contain info 964 // for more than one table or we could emulating ON DELETE CASCADE, etc. 965 $con->begin(); 689 $affectedRows = 0; try { 690 $con->begin(); 966 691 $affectedRows += BasePeer::doDeleteAll(InterestPeer::TABLE_NAME, $con); 967 692 $con->commit(); … … 973 698 } 974 699 975 /** 976 * Method perform a DELETE on the database, given a Interest or Criteria object OR a primary key value. 977 * 978 * @param mixed $values Criteria or Interest object or primary key or array of primary keys 979 * which is used to create the DELETE statement 980 * @param Connection $con the connection to use 981 * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows 982 * if supported by native driver or if emulated using Propel. 983 * @throws PropelException Any exceptions caught during processing will be 984 * rethrown wrapped into a PropelException. 985 */ 700 986 701 public static function doDelete($values, $con = null) 987 702 { … … 991 706 992 707 if ($values instanceof Criteria) { 993 $criteria = clone $values; // rename for clarity 994 } elseif ($values instanceof Interest) { 708 $criteria = clone $values; } elseif ($values instanceof Interest) { 995 709 996 710 $criteria = $values->buildPkeyCriteria(); 997 711 } else { 998 // it must be the primary key 999 $criteria = new Criteria(self::DATABASE_NAME); 1000 // primary key is composite; we therefore, expect 1001 // the primary key passed to be an array of pkey 1002 // values 1003 if(count($values) == count($values, COUNT_RECURSIVE)) 712 $criteria = new Criteria(self::DATABASE_NAME); 713 if(count($values) == count($values, COUNT_RECURSIVE)) 1004 714 { 1005 // array is not multi-dimensional 1006 $values = array($values); 715 $values = array($values); 1007 716 } 1008 717 $vals = array(); … … 1018 727 } 1019 728 1020 // Set the correct dbName 1021 $criteria->setDbName(self::DATABASE_NAME); 1022 1023 $affectedRows = 0; // initialize var to track total num of affected rows 1024 729 $criteria->setDbName(self::DATABASE_NAME); 730 731 $affectedRows = 0; 1025 732 try { 1026 // use transaction because $criteria could contain info 1027 // for more than one table or we could emulating ON DELETE CASCADE, etc. 1028 $con->begin(); 733 $con->begin(); 1029 734 1030 735 $affectedRows += BasePeer::doDelete($criteria, $con); … … 1037 742 } 1038 743 1039 /** 1040 * Validates all modified columns of given Interest object. 1041 * If parameter $columns is either a single column name or an array of column names 1042 * than only those columns are validated. 1043 * 1044 * NOTICE: This does not apply to primary or foreign keys for now. 1045 * 1046 * @param Interest $obj The object to validate. 1047 * @param mixed $cols Column name or array of column names. 1048 * 1049 * @return mixed TRUE if all columns are valid or the error message of the first invalid column. 1050 */ 744 1051 745 public static function doValidate(Interest $obj, $cols = null) 1052 746 { … … 1083 777 } 1084 778 1085 /** 1086 * Retrieve object using using composite pkey values. 1087 * @param int $question_id 1088 @param int $user_id 1089 1090 * @param Connection $con 1091 * @return Interest 1092 */ 779 1093 780 public static function retrieveByPK( $question_id, $user_id, $con = null) { 1094 781 if ($con === null) { … … 1099 786 $criteria->add(InterestPeer::USER_ID, $user_id); 1100 787 $v = InterestPeer::doSelect($criteria, $con); 1101 return !empty($v) ? $v[0] : null; 1102 } 1103 } // BaseInterestPeer 1104 1105 // static code to register the map builder for this Peer with the main Propel class 788 789 return !empty($v) ? $v[0] : null; 790 } 791 } 1106 792 if (Propel::isInit()) { 1107 // the MapBuilder classes register themselves with Propel during initialization 1108 // so we need to load them here. 1109 try { 793 try { 1110 794 BaseInterestPeer::getMapBuilder(); 1111 795 } catch (Exception $e) { … … 1113 797 } 1114 798 } else { 1115 // even if Propel is not yet initialized, the map builder class can be registered 1116 // now and then it will be loaded when Propel initializes. 1117 require_once 'model/map/InterestMapBuilder.php'; 1118 Propel::registerMapBuilder('model.map.InterestMapBuilder'); 799 require_once 'lib/model/map/InterestMapBuilder.php'; 800 Propel::registerMapBuilder('lib.model.map.InterestMapBuilder'); 1119 801 } trunk/lib/model/om/BaseQuestion.php
r74 r88 1 1 <?php 2 2 3 require_once 'propel/om/BaseObject.php'; 4 5 require_once 'propel/om/Persistent.php'; 6 7 8 include_once 'propel/util/Criteria.php'; 9 10 include_once 'model/QuestionPeer.php'; 11 12 /** 13 * Base class that represents a row from the 'ask_question' table. 14 * 15 * 16 * 17 * @package model.om 18 */ 3 19 4 abstract class BaseQuestion extends BaseObject implements Persistent { 20 5 21 6 22 /** 23 * The Peer class. 24 * Instance provides a convenient way of calling static methods on a class 25 * that calling code may not be able to identify. 26 * @var QuestionPeer 27 */ 7 8 const DATABASE_NAME = 'symfony'; 9 10 28 11 protected static $peer; 29 12 30 13 31 /** 32 * The value for the id field. 33 * @var int 34 */ 14 35 15 protected $id; 36 16 37 17 38 /** 39 * The value for the user_id field. 40 * @var int 41 */ 18 42 19 protected $user_id; 43 20 44 21 45 /** 46 * The value for the title field. 47 * @var string 48 */ 22 49 23 protected $title; 50 24 51 25 52 /** 53 * The value for the stripped_title field. 54 * @var string 55 */ 26 56 27 protected $stripped_title; 57 28 58 29 59 /** 60 * The value for the body field. 61 * @var string 62 */ 30 63 31 protected $body; 64 32 65 33 66 /** 67 * The value for the html_body field. 68 * @var string 69 */ 34 70 35 protected $html_body; 71 36 72 37 73 /** 74 * The value for the interested_users field. 75 * @var int 76 */ 38 77 39 protected $interested_users = 0; 78 40 79 41 80 /** 81 * The value for the reports field. 82 * @var int 83 */ 42 84 43 protected $reports = 0; 85 44 86 45 87 /** 88 * The value for the created_at field. 89 * @var int 90 */ 46 91 47 protected $created_at; 92 48 93 49 94 /** 95 * The value for the updated_at field. 96 * @var int 97 */ 50 98 51 protected $updated_at; 99 52 100 /** 101 * @var User 102 */ 53 103 54 protected $aUser; 104 55 105 /** 106 * Collection to store aggregation of collAnswers. 107 * @var array 108 */ 56 109 57 protected $collAnswers; 110 111 /** 112 * The criteria used to select the current contents of collAnswers. 113 * @var Criteria 114 */ 115 private $lastAnswerCriteria = null; 116 117 /** 118 * Collection to store aggregation of collInterests. 119 * @var array 120 */ 58 59 60 protected $lastAnswerCriteria = null; 61 62 121 63 protected $collInterests; 122 123 /** 124 * The criteria used to select the current contents of collInterests. 125 * @var Criteria 126 */ 127 private $lastInterestCriteria = null; 128 129 /** 130 * Collection to store aggregation of collQuestionTags. 131 * @var array 132 */ 64 65 66 protected $lastInterestCriteria = null; 67 68 133 69 protected $collQuestionTags; 134 135 /** 136 * The criteria used to select the current contents of collQuestionTags. 137 * @var Criteria 138 */ 139 private $lastQuestionTagCriteria = null; 140 141 /** 142 * Collection to store aggregation of collSearchIndexs. 143 * @var array 144 */ 70 71 72 protected $lastQuestionTagCriteria = null; 73 74 145 75 protected $collSearchIndexs; 146 147 /** 148 * The criteria used to select the current contents of collSearchIndexs. 149 * @var Criteria 150 */ 151 private $lastSearchIndexCriteria = null; 152 153 /** 154 * Collection to store aggregation of collReportQuestions. 155 * @var array 156 */ 76 77 78 protected $lastSearchIndexCriteria = null; 79 80 157 81 protected $collReportQuestions; 158 159 /** 160 * The criteria used to select the current contents of collReportQuestions. 161 * @var Criteria 162 */ 163 private $lastReportQuestionCriteria = null; 164 165 /** 166 * Flag to prevent endless save loop, if this object is referenced 167 * by another object which falls in this transaction. 168 * @var boolean 169 */ 82 83 84 protected $lastReportQuestionCriteria = null; 85 86 170 87 protected $alreadyInSave = false; 171 88 172 /** 173 * Flag to prevent endless validation loop, if this object is referenced 174 * by another object which falls in this transaction. 175 * @var boolean 176 */ 89 177 90 protected $alreadyInValidation = false; 178 91 179 /** 180 * Get the [id] column value. 181 * 182 * @return int 183 */ 92 184 93 public function getId() 185 94 { … … 188 97 } 189 98 190 /** 191 * Get the [user_id] column value. 192 * 193 * @return int 194 */ 99 195 100 public function getUserId() 196 101 { … … 199 104 } 200 105 201 /** 202 * Get the [title] column value. 203 * 204 * @return string 205 */ 106 206 107 public function getTitle() 207 108 { … … 210 111 } 211 112 212 /** 213 * Get the [stripped_title] column value. 214 * 215 * @return string 216 */ 113 217 114 public function getStrippedTitle() 218 115 { … … 221 118 } 222 119 223 /** 224 * Get the [body] column value. 225 * 226 * @return string 227 */ 120 228 121 public function getBody() 229 122 { … … 232 125 } 233 126 234 /** 235 * Get the [html_body] column value. 236 * 237 * @return string 238 */ 127 239 128 public function getHtmlBody() 240 129 { … … 243 132 } 244 133 245 /** 246 * Get the [interested_users] column value. 247 * 248 * @return int 249 */ 134 250 135 public function getInterestedUsers() 251 136 { … … 254 139 } 255 140 256 /** 257 * Get the [reports] column value. 258 * 259 * @return int 260 */ 141 261 142 public function getReports() 262 143 { … … 265 146 } 266 147 267 /** 268 * Get the [optionally formatted] [created_at] column value. 269 * 270 * @param string $format The date/time format string (either date()-style or strftime()-style). 271 * If format is NULL, then the integer unix timestamp will be returned. 272 * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). 273 * @throws PropelException - if unable to convert the date/time to timestamp. 274 */ 148 275 149 public function getCreatedAt($format = 'Y-m-d H:i:s') 276 150 { … … 279 153 return null; 280 154 } elseif (!is_int($this->created_at)) { 281 // a non-timestamp value was set externally, so we convert it 282 $ts = strtotime($this->created_at); 283 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 284 throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); 155 $ts = strtotime($this->created_at); 156 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); 285 157 } 286 158 } else { … … 296 168 } 297 169 298 /** 299 * Get the [optionally formatted] [updated_at] column value. 300 * 301 * @param string $format The date/time format string (either date()-style or strftime()-style). 302 * If format is NULL, then the integer unix timestamp will be returned. 303 * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). 304 * @throws PropelException - if unable to convert the date/time to timestamp. 305 */ 170 306 171 public function getUpdatedAt($format = 'Y-m-d H:i:s') 307 172 { … … 310 175 return null; 311 176 } elseif (!is_int($this->updated_at)) { 312 // a non-timestamp value was set externally, so we convert it 313 $ts = strtotime($this->updated_at); 314 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 315 throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true)); 177 $ts = strtotime($this->updated_at); 178 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true)); 316 179 } 317 180 } else { … … 327 190 } 328 191 329 /** 330 * Set the value of [id] column. 331 * 332 * @param int $v new value 333 * @return void 334 */ 192 335 193 public function setId($v) 336 194 { … … 341 199 } 342 200 343 } // setId() 344 345 /** 346 * Set the value of [user_id] column. 347 * 348 * @param int $v new value 349 * @return void 350 */ 201 } 202 351 203 public function setUserId($v) 352 204 { … … 359 211 if ($this->aUser !== null && $this->aUser->getId() !== $v) { 360 212 $this->aUser = null; 361 } 362 363 } // setUserId() 364 365 /** 366 * Set the value of [title] column. 367 * 368 * @param string $v new value 369 * @return void 370 */ 213 } 214 215 } 216 371 217 public function setTitle($v) 372 218 { … … 377 223 } 378 224 379 } // setTitle() 380 381 /** 382 * Set the value of [stripped_title] column. 383 * 384 * @param string $v new value 385 * @return void 386 */ 225 } 226 387 227 public function setStrippedTitle($v) 388 228 { … … 393 233 } 394 234 395 } // setStrippedTitle() 396 397 /** 398 * Set the value of [body] column. 399 * 400 * @param string $v new value 401 * @return void 402 */ 235 } 236 403 237 public function setBody($v) 404 238 { … … 409 243 } 410 244 411 } // setBody() 412 413 /** 414 * Set the value of [html_body] column. 415 * 416 * @param string $v new value 417 * @return void 418 */ 245 } 246 419 247 public function setHtmlBody($v) 420 248 { … … 425 253 } 426 254 427 } // setHtmlBody() 428 429 /** 430 * Set the value of [interested_users] column. 431 * 432 * @param int $v new value 433 * @return void 434 */ 255 } 256 435 257 public function setInterestedUsers($v) 436 258 { … … 441 263 } 442 264 443 } // setInterestedUsers() 444 445 /** 446 * Set the value of [reports] column. 447 * 448 * @param int $v new value 449 * @return void 450 */ 265 } 266 451 267 public function setReports($v) 452 268 { … … 457 273 } 458 274 459 } // setReports() 460 461 /** 462 * Set the value of [created_at] column. 463 * 464 * @param int $v new value 465 * @return void 466 */ 275 } 276 467 277 public function setCreatedAt($v) 468 278 { … … 470 280 if ($v !== null && !is_int($v)) { 471 281 $ts = strtotime($v); 472 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 473 throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); 282 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); 474 283 } 475 284 } else { … … 481 290 } 482 291 483 } // setCreatedAt() 484 485 /** 486 * Set the value of [updated_at] column. 487 * 488 * @param int $v new value 489 * @return void 490 */ 292 } 293 491 294 public function setUpdatedAt($v) 492 295 { … … 494 297 if ($v !== null && !is_int($v)) { 495 298 $ts = strtotime($v); 496 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 497 throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true)); 299 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true)); 498 300 } 499 301 } else { … … 505 307 } 506 308 507 } // setUpdatedAt() 508 509 /** 510 * Hydrates (populates) the object variables with values from the database resultset. 511 * 512 * An offset (1-based "start column") is specified so that objects can be hydrated 513 * with a subset of the columns in the resultset rows. This is needed, for example, 514 * for results of JOIN queries where the resultset row includes columns from two or 515 * more tables. 516 * 517 * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. 518 * @param int $startcol 1-based offset column which indicates which restultset column to start with. 519 * @return int next starting column 520 * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. 521 */ 309 } 310 522 311 public function hydrate(ResultSet $rs, $startcol = 1) 523 312 { … … 548 337 $this->setNew(false); 549 338 550 // FIXME - using NUM_COLUMNS may be clearer. 551 return $startcol + 10; // 10 = QuestionPeer::NUM_COLUMNS - QuestionPeer::NUM_LAZY_LOAD_COLUMNS). 552 339 return $startcol + 10; 553 340 } catch (Exception $e) { 554 341 throw new PropelException("Error populating Question object", $e); … … 556 343 } 557 344 558 /** 559 * Removes this object from datastore and sets delete attribute. 560 * 561 * @param Connection $con 562 * @return void 563 * @throws PropelException 564 * @see BaseObject::setDeleted() 565 * @see BaseObject::isDeleted() 566 */ 345 567 346 public function delete($con = null) 568 347 { … … 586 365 } 587 366 588 /** 589 * Stores the object in the database. If the object is new, 590 * it inserts it; otherwise an update is performed. This method 591 * wraps the doSave() worker method in a transaction. 592 * 593 * @param Connection $con 594 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. 595 * @throws PropelException 596 * @see doSave() 597 */ 367 598 368 public function save($con = null) 599 369 { 600 if ($this->isNew() )370 if ($this->isNew() && !$this->isColumnModified(QuestionPeer::CREATED_AT)) 601 371 { 602 372 $this->setCreatedAt(time()); 603 373 } 604 $this->setUpdatedAt(time()); 374 375 if ($this->isModified() && !$this->isColumnModified(QuestionPeer::UPDATED_AT)) 376 { 377 $this->setUpdatedAt(time()); 378 } 605 379 606 380 if ($this->isDeleted()) { … … 611 385 $con = Propel::getConnection(QuestionPeer::DATABASE_NAME); 612 386 } 613 387 614 388 try { 615 389 $con->begin(); … … 623 397 } 624 398 625 /** 626 * Stores the object in the database. 627 * 628 * If the object is new, it inserts it; otherwise an update is performed. 629 * All related objects are also updated in this method. 630 * 631 * @param Connection $con 632 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. 633 * @throws PropelException 634 * @see save() 635 */ 399 636 400 protected function doSave($con) 637 401 { 638 $affectedRows = 0; // initialize var to track total num of affected rows 639 if (!$this->alreadyInSave) { 402 $affectedRows = 0; if (!$this->alreadyInSave) { 640 403 $this->alreadyInSave = true; 641 404 642 405 643 // We call the save method on the following object(s) if they 644 // were passed to this object by their coresponding set 645 // method. This object relates to these object(s) by a 646 // foreign key reference. 647 406 648 407 if ($this->aUser !== null) { 649 408 if ($this->aUser->isModified()) { … … 652 411 $this->setUser($this->aUser); 653 412 } 654 655 656 // If this object has been modified, then save it to the database. 657 if ($this->isModified()) { 413 414 415 if ($this->isModified()) { 658 416 if ($this->isNew()) { 659 417 $pk = QuestionPeer::doInsert($this, $con); 660 $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which 661 // should always be true here (even though technically 662 // BasePeer::doInsert() can insert multiple rows). 663 664 $this->setId($pk); //[IMV] update autoincrement primary key 665 418 $affectedRows += 1; 419 $this->setId($pk); 666 420 $this->setNew(false); 667 421 } else { 668 422 $affectedRows += QuestionPeer::doUpdate($this, $con); 669 423 } 670 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 671 } 424 $this->resetModified(); } 672 425 673 426 if ($this->collAnswers !== null) { … … 714 467 } 715 468 return $affectedRows; 716 } // doSave() 717 718 /** 719 * Array of ValidationFailed objects. 720 * @var array ValidationFailed[] 721 */ 469 } 470 722 471 protected $validationFailures = array(); 723 472 724 /** 725 * Gets any ValidationFailed objects that resulted from last call to validate(). 726 * 727 * 728 * @return array ValidationFailed[] 729 * @see validate() 730 */ 473 731 474 public function getValidationFailures() 732 475 { … … 734 477 } 735 478 736 /** 737 * Validates the objects modified field values and all objects related to this table. 738 * 739 * If $columns is either a column name or an array of column names 740 * only those columns are validated. 741 * 742 * @param mixed $columns Column name or an array of column names. 743 * @return boolean Whether all columns pass validation. 744 * @see doValidate() 745 * @see getValidationFailures() 746 */ 479 747 480 public function validate($columns = null) 748 481 { … … 757 490 } 758 491 759 /** 760 * This function performs the validation work for complex object models. 761 * 762 * In addition to checking the current object, all related objects will 763 * also be validated. If all pass then <code>true</code> is returned; otherwise 764 * an aggreagated array of ValidationFailed objects will be returned. 765 * 766 * @param array $columns Array of column names to validate. 767 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 768 */ 492 769 493 protected function doValidate($columns = null) 770 494 { … … 776 500 777 501 778 // We call the validate method on the following object(s) if they 779 // were passed to this object by their coresponding set 780 // method. This object relates to these object(s) by a 781 // foreign key reference. 782 502 783 503 if ($this->aUser !== null) { 784 504 if (!$this->aUser->validate($columns)) { … … 840 560 } 841 561 842 /** 843 * Retrieves a field from the object by name passed in as a string. 844 * 845 * @param string $name name 846 * @param string $type The type of fieldname the $name is of: 847 * one of the class type constants TYPE_PHPNAME, 848 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 849 * @return mixed Value of field. 850 */ 562 851 563 public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 852 564 { … … 855 567 } 856 568 857 /** 858 * Retrieves a field from the object by Position as specified in the xml schema. 859 * Zero-based. 860 * 861 * @param int $pos position in xml schema 862 * @return mixed Value of field at $pos 863 */ 569 864 570 public function getByPosition($pos) 865 571 { … … 898 604 return null; 899 605 break; 900 } // switch() 901 } 902 903 /** 904 * Exports the object as an array. 905 * 906 * You can specify the key type of the array by passing one of the class 907 * type constants. 908 * 909 * @param string $keyType One of the class type constants TYPE_PHPNAME, 910 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 911 * @return an associative array containing the field names (as keys) and field values 912 */ 606 } } 607 608 913 609 public function toArray($keyType = BasePeer::TYPE_PHPNAME) 914 610 { … … 929 625 } 930 626 931 /** 932 * Sets a field from the object by name passed in as a string. 933 * 934 * @param string $name peer name 935 * @param mixed $value field value 936 * @param string $type The type of fieldname the $name is of: 937 * one of the class type constants TYPE_PHPNAME, 938 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 939 * @return void 940 */ 627 941 628 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 942 629 { … … 945 632 } 946 633 947 /** 948 * Sets a field from the object by Position as specified in the xml schema. 949 * Zero-based. 950 * 951 * @param int $pos position in xml schema 952 * @param mixed $value field value 953 * @return void 954 */ 634 955 635 public function setByPosition($pos, $value) 956 636 { … … 986 666 $this->setUpdatedAt($value); 987 667 break; 988 } // switch() 989 } 990 991 /** 992 * Populates the object using an array. 993 * 994 * This is particularly useful when populating an object from one of the 995 * request arrays (e.g. $_POST). This method goes through the column 996 * names, checking to see whether a matching key exists in populated 997 * array. If so the setByName() method is called for that column. 998 * 999 * You can specify the key type of the array by additionally passing one 1000 * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, 1001 * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') 1002 * 1003 * @param array $arr An array to populate the object from. 1004 * @param string $keyType The type of keys the array uses. 1005 * @return void 1006 */ 668 } } 669 670 1007 671 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) 1008 672 { … … 1021 685 } 1022 686 1023 /** 1024 * Build a Criteria object containing the values of all modified columns in this object. 1025 * 1026 * @return Criteria The Criteria object containing all modified values. 1027 */ 687 1028 688 public function buildCriteria() 1029 689 { … … 1044 704 } 1045 705 1046 /** 1047 * Builds a Criteria object containing the primary key for this object. 1048 * 1049 * Unlike buildCriteria() this method includes the primary key values regardless 1050 * of whether or not they have been modified. 1051 * 1052 * @return Criteria The Criteria object containing value(s) for primary key(s). 1053 */ 706 1054 707 public function buildPkeyCriteria() 1055 708 { … … 1061 714 } 1062 715 1063 /** 1064 * Returns the primary key for this object (row). 1065 * @return int 1066 */ 716 1067 717 public function getPrimaryKey() 1068 718 { … … 1070 720 } 1071 721 1072 /** 1073 * Generic method to set the primary key (id column). 1074 * 1075 * @param int $key Primary key. 1076 * @return void 1077 */ 722 1078 723 public function setPrimaryKey($key) 1079 724 { … … 1081 726 } 1082 727 1083 /** 1084 * Sets contents of passed object to values from current object. 1085 * 1086 * If desired, this method can also make copies of all associated (fkey referrers) 1087 * objects. 1088 * 1089 * @param object $copyObj An object of Question (or compatible) type. 1090 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 1091 * @throws PropelException 1092 */ 728 1093 729 public function copyInto($copyObj, $deepCopy = false) 1094 730 { … … 1114 750 1115 751 if ($deepCopy) { 1116 // important: temporarily setNew(false) because this affects the behavior of 1117 // the getter/setter methods for fkey referrer objects. 1118 $copyObj->setNew(false); 752 $copyObj->setNew(false); 1119 753 1120 754 foreach($this->getAnswers() as $relObj) { 1121 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1122 $copyObj->addAnswer($relObj->copy($deepCopy)); 1123 } 755 $copyObj->addAnswer($relObj->copy($deepCopy)); 1124 756 } 1125 757 1126 758 foreach($this->getInterests() as $relObj) { 1127 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1128 $copyObj->addInterest($relObj->copy($deepCopy)); 1129 } 759 $copyObj->addInterest($relObj->copy($deepCopy)); 1130 760 } 1131 761 1132 762 foreach($this->getQuestionTags() as $relObj) { 1133 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1134 $copyObj->addQuestionTag($relObj->copy($deepCopy)); 1135 } 763 $copyObj->addQuestionTag($relObj->copy($deepCopy)); 1136 764 } 1137 765 1138 766 foreach($this->getSearchIndexs() as $relObj) { 1139 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1140 $copyObj->addSearchIndex($relObj->copy($deepCopy)); 1141 } 767 $copyObj->addSearchIndex($relObj->copy($deepCopy)); 1142 768 } 1143 769 1144 770 foreach($this->getReportQuestions() as $relObj) { 1145 if($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves 1146 $copyObj->addReportQuestion($relObj->copy($deepCopy)); 1147 } 1148 } 1149 1150 } // if ($deepCopy) 1151 771 $copyObj->addReportQuestion($relObj->copy($deepCopy)); 772 } 773 774 } 1152 775 1153 776 $copyObj->setNew(true); 1154 777 1155 $copyObj->setId(NULL); // this is a pkey column, so set to default value 1156 1157 } 1158 1159 /** 1160 * Makes a copy of this object that will be inserted as a new row in table when saved. 1161 * It creates a new object filling in the simple attributes, but skipping any primary 1162 * keys that are defined for the table. 1163 * 1164 * If desired, this method can also make copies of all associated (fkey referrers) 1165 * objects. 1166 * 1167 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 1168 * @return Question Clone of current object. 1169 * @throws PropelException 1170 */ 778 $copyObj->setId(NULL); 779 } 780 781 1171 782 public function copy($deepCopy = false) 1172 783 { 1173 // we use get_class(), because this might be a subclass 1174 $clazz = get_class($this); 784 $clazz = get_class($this); 1175 785 $copyObj = new $clazz(); 1176 786 $this->copyInto($copyObj, $deepCopy); … … 1178 788 } 1179 789 1180 /** 1181 * Returns a peer instance associated with this om. 1182 * 1183 * Since Peer classes are not to have any instance attributes, this method returns the 1184 * same instance for all member of this class. The method could therefore 1185 * be static, but this would prevent one from overriding the behavior. 1186 * 1187 * @return QuestionPeer 1188 */ 790 1189 791 public function getPeer() 1190 792 { … … 1195 797 } 1196 798 1197 /** 1198 * Declares an association between this object and a User object. 1199 * 1200 * @param User $v 1201 * @return void 1202 * @throws PropelException 1203 */ 799 1204 800 public function setUser($v) 1205 801 { … … 1217 813 1218 814 1219 /** 1220 * Get the associated User object 1221 * 1222 * @param Connection Optional Connection object. 1223 * @return User The associated User object. 1224 * @throws PropelException 1225 */ 815 1226 816 public function getUser($con = null) 1227 817 { 1228 // include the related Peer class 1229 include_once 'model/om/BaseUserPeer.php'; 818 include_once 'lib/model/om/BaseUserPeer.php'; 1230 819 1231 820 if ($this->aUser === null && ($this->user_id !== null)) { 1232 821 1233 822 $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); 1234 1235 /* The following can be used instead of the line above to 1236 guarantee the related object contains a reference 1237 to this object, but this level of coupling 1238 may be undesirable in many circumstances. 1239 As it can lead to a db query with many results that may 1240 never be used. 1241 $obj = UserPeer::retrieveByPK($this->user_id, $con); 1242 $obj->addUsers($this); 1243 */ 823 824 1244 825 } 1245 826 return $this->aUser; 1246 827 } 1247 828 1248 /** 1249 * Temporary storage of collAnswers to save a possible db hit in 1250 * the event objects are add to the collection, but the 1251 * complete collection is never requested. 1252 * @return void 1253 */ 829 1254 830 public function initAnswers() 1255 831 { … … 1259 835 } 1260 836 1261 /** 1262 * If this collection has already been initialized with 1263 * an identical criteria, it returns the collection. 1264 * Otherwise if this Question has previously 1265 * been saved, it will retrieve related Answers from storage. 1266 * If this Question is new, it will return 1267 * an empty collection or the current collection, the criteria 1268 * is ignored on a new object. 1269 * 1270 * @param Connection $con 1271 * @param Criteria $criteria 1272 * @throws PropelException 1273 */ 837 1274 838 public function getAnswers($criteria = null, $con = null) 1275 839 { 1276 // include the Peer class 1277 include_once 'model/om/BaseAnswerPeer.php'; 840 include_once 'lib/model/om/BaseAnswerPeer.php'; 1278 841 if ($criteria === null) { 1279 842 $criteria = new Criteria(); … … 1295 858 } 1296 859 } else { 1297 // criteria has no effect for a new object 1298 if (!$this->isNew()) { 1299 // the following code is to determine if a new query is 1300 // called for. If the criteria is the same as the last 1301 // one, just return the collection. 1302 860 if (!$this->isNew()) { 861 1303 862 1304 863 $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); … … 1314 873 } 1315 874 1316 /** 1317 * Returns the number of related Answers. 1318 * 1319 * @param Criteria $criteria 1320 * @param boolean $distinct 1321 * @param Connection $con 1322 * @throws PropelException 1323 */ 875 1324 876 public function countAnswers($criteria = null, $distinct = false, $con = null) 1325 877 { 1326 // include the Peer class 1327 include_once 'model/om/BaseAnswerPeer.php'; 878 include_once 'lib/model/om/BaseAnswerPeer.php'; 1328 879 if ($criteria === null) { 1329 880 $criteria = new Criteria(); … … 1339 890 } 1340 891 1341 /** 1342 * Method called to associate a Answer object to this object 1343 * through the Answer foreign key attribute 1344 * 1345 * @param Answer $l Answer 1346 * @return void 1347 * @throws PropelException 1348 */ 892 1349 893 public function addAnswer(Answer $l) 1350 894 { … … 1354 898 1355 899 1356 /** 1357 * If this collection has already been initialized with 1358 * an identical criteria, it returns the collection. 1359 * Otherwise if this Question is new, it will return 1360 * an empty collection; or if this Question has previously 1361 * been saved, it will retrieve related Answers from storage. 1362 * 1363 * This method is protected by default in order to keep the public 1364 * api reasonable. You can provide public methods for those you 1365 * actually need in Question. 1366 */ 900 1367 901 public function getAnswersJoinUser($criteria = null, $con = null) 1368 902 { 1369 // include the Peer class 1370 include_once 'model/om/BaseAnswerPeer.php'; 903 include_once 'lib/model/om/BaseAnswerPeer.php'; 1371 904 if ($criteria === null) { 1372 905 $criteria = new Criteria(); … … 1387 920 } 1388 921 } else { 1389 // the following code is to determine if a new query is 1390 // called for. If the criteria is the same as the last 1391 // one, just return the collection. 1392 922 1393 923 $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); 1394 924 … … 1402 932 } 1403 933 1404 /** 1405 * Temporary storage of collInterests to save a possible db hit in 1406 * the event objects are add to the collection, but the 1407 * complete collection is never requested. 1408 * @return void 1409 */ 934 1410 935 public function initInterests() 1411 936 { … … 1415 940 } 1416 941 1417 /** 1418 * If this collection has already been initialized with 1419 * an identical criteria, it returns the collection. 1420 * Otherwise if this Question has previously 1421 * been saved, it will retrieve related Interests from storage. 1422 * If this Question is new, it will return 1423 * an empty collection or the current collection, the criteria 1424 * is ignored on a new object. 1425 * 1426 * @param Connection $con 1427 * @param Criteria $criteria 1428 * @throws PropelException 1429 */ 942 1430 943 public function getInterests($criteria = null, $con = null) 1431 944 { 1432 // include the Peer class 1433 include_once 'model/om/BaseInterestPeer.php'; 945 include_once 'lib/model/om/BaseInterestPeer.php'; 1434 946 if ($criteria === null) { 1435 947 $criteria = new Criteria(); … … 1451 963 } 1452 964 } else { 1453 // criteria has no effect for a new object 1454 if (!$this->isNew()) { 1455 // the following code is to determine if a new query is 1456 // called for. If the criteria is the same as the last 1457 // one, just return the collection. 1458 965 if (!$this->isNew()) { 966 1459 967 1460 968 $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); … … 1470 978 } 1471 979 1472 /** 1473 * Returns the number of related Interests. 1474 * 1475 * @param Criteria $criteria 1476 * @param boolean $distinct 1477 * @param Connection $con 1478 * @throws PropelException 1479 */ 980 1480 981 public function countInterests($criteria = null, $distinct = false, $con = null) 1481 982 { 1482 // include the Peer class 1483 include_once 'model/om/BaseInterestPeer.php'; 983 include_once 'lib/model/om/BaseInterestPeer.php'; 1484 984 if ($criteria === null) { 1485 985 $criteria = new Criteria(); … … 1495 995 } 1496 996 1497 /** 1498 * Method called to associate a Interest object to this object 1499 * through the Interest foreign key attribute 1500 * 1501 * @param Interest $l Interest 1502 * @return void 1503 * @throws PropelException 1504 */ 997 1505 998 public function addInterest(Interest $l) 1506 999 { … … 1510 1003 1511 1004 1512 /** 1513 * If this collection has already been initialized with 1514 * an identical criteria, it returns the collection. 1515 * Otherwise if this Question is new, it will return 1516 * an empty collection; or if this Question has previously 1517 * been saved, it will retrieve related Interests from storage. 1518 * 1519 * This method is protected by default in order to keep the public 1520 * api reasonable. You can provide public methods for those you 1521 * actually need in Question. 1522 */ 1005 1523 1006 public function getInterestsJoinUser($criteria = null, $con = null) 1524 1007 { 1525 // include the Peer class 1526 include_once 'model/om/BaseInterestPeer.php'; 1008 include_once 'lib/model/om/BaseInterestPeer.php'; 1527 1009 if ($criteria === null) { 1528 1010 $criteria = new Criteria(); … … 1543 1025 } 1544 1026 } else { 1545 // the following code is to determine if a new query is 1546 // called for. If the criteria is the same as the last 1547 // one, just return the collection. 1548 1027 1549 1028 $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); 1550 1029 … … 1558 1037 } 1559 1038 1560 /** 1561 * Temporary storage of collQuestionTags to save a possible db hit in 1562 * the event objects are add to the collection, but the 1563 * complete collection is never requested. 1564 * @return void 1565 */ 1039 1566 1040 public function initQuestionTags() 1567 1041 { … … 1571 1045 } 1572 1046 1573 /** 1574 * If this collection has already been initialized with 1575 * an identical criteria, it returns the collection. 1576 * Otherwise if this Question has previously 1577 * been saved, it will retrieve related QuestionTags from storage. 1578 * If this Question is new, it will return 1579 * an empty collection or the current collection, the criteria 1580 * is ignored on a new object. 1581 * 1582 * @param Connection $con 1583 * @param Criteria $criteria 1584 * @throws PropelException 1585 */ 1047 1586 1048 public function getQuestionTags($criteria = null, $con = null) 1587 1049 { 1588 // include the Peer class 1589 include_once 'model/om/BaseQuestionTagPeer.php'; 1050 include_once 'lib/model/om/BaseQuestionTagPeer.php'; 1590 1051 if ($criteria === null) { 1591 1052 $criteria = new Criteria(); … … 1607 1068 } 1608 1069 } else { 1609 // criteria has no effect for a new object 1610 if (!$this->isNew()) { 1611 // the following code is to determine if a new query is 1612 // called for. If the criteria is the same as the last 1613 // one, just return the collection. 1614 1070 if (!$this->isNew()) { 1071 1615 1072 1616 1073 $criteria->add(QuestionTagPeer::QUESTION_ID, $this->getId()); … … 1626 1083 } 1627 1084 1628 /** 1629 * Returns the number of related QuestionTags. 1630 * 1631 * @param Criteria $criteria 1632 * @param boolean $distinct 1633 * @param Connection $con 1634 * @throws PropelException 1635 */ 1085 1636 1086 public function countQuestionTags($criteria = null, $distinct = false, $con = null) 1637 1087 { 1638 // include the Peer class 1639 include_once 'model/om/BaseQuestionTagPeer.php'; 1088 include_once 'lib/model/om/BaseQuestionTagPeer.php'; 1640 1089 if ($criteria === null) { 1641 1090 $criteria = new Criteria(); … … 1651 1100 } 1652 1101 1653 /** 1654 * Method called to associate a QuestionTag object to this object 1655 * through the QuestionTag foreign key attribute 1656 * 1657 * @param QuestionTag $l QuestionTag 1658 * @return void 1659 * @throws PropelException 1660 */ 1102 1661 1103 public function addQuestionTag(QuestionTag $l) 1662 1104 { … … 1666 1108 1667 1109 1668 /** 1669 * If this collection has already been initialized with 1670 * an identical criteria, it returns the collection. 1671 * Otherwise if this Question is new, it will return 1672 * an empty collection; or if this Question has previously 1673 * been saved, it will retrieve related QuestionTags from storage. 1674 * 1675 * This method is protected by default in order to keep the public 1676 * api reasonable. You can provide public methods for those you 1677 * actually need in Question. 1678 */ 1110 1679 1111 public function getQuestionTagsJoinUser($criteria = null, $con = null) 1680 1112 { 1681 // include the Peer class 1682 include_once 'model/om/BaseQuestionTagPeer.php'; 1113 include_once 'lib/model/om/BaseQuestionTagPeer.php'; 1683 1114 if ($criteria === null) { 1684 1115 $criteria = new Criteria(); … … 1699 1130 } 1700 1131 } else { 1701 // the following code is to determine if a new query is 1702 // called for. If the criteria is the same as the last 1703 // one, just return the collection. 1704 1132 1705 1133 $criteria->add(QuestionTagPeer::QUESTION_ID, $this->getId()); 1706 1134 … … 1714 1142 } 1715 1143 1716 /** 1717 * Temporary storage of collSearchIndexs to save a possible db hit in 1718 * the event objects are add to the collection, but the 1719 * complete collection is never requested. 1720 * @return void 1721 */ 1144 1722 1145 public function initSearchIndexs() 1723 1146 { … … 1727 1150 } 1728 1151 1729 /** 1730 * If this collection has already been initialized with 1731 * an identical criteria, it returns the collection. 1732 * Otherwise if this Question has previously 1733 * been saved, it will retrieve related SearchIndexs from storage. 1734 * If this Question is new, it will return 1735 * an empty collection or the current collection, the criteria 1736 * is ignored on a new object. 1737 * 1738 * @param Connection $con 1739 * @param Criteria $criteria 1740 * @throws PropelException 1741 */ 1152 1742 1153 public function getSearchIndexs($criteria = null, $con = null) 1743 1154 { 1744 // include the Peer class 1745 include_once 'model/om/BaseSearchIndexPeer.php'; 1155 include_once 'lib/model/om/BaseSearchIndexPeer.php'; 1746 1156 if ($criteria === null) { 1747 1157 $criteria = new Criteria(); … … 1763 1173 } 1764 1174 } else { 1765 // criteria has no effect for a new object 1766 if (!$this->isNew()) { 1767 // the following code is to determine if a new query is 1768 // called for. If the criteria is the same as the last 1769 // one, just return the collection. 1770 1175 if (!$this->isNew()) { 1176 1771 1177 1772 1178 $criteria->add(SearchIndexPeer::QUESTION_ID, $this->getId()); … … 1782 1188 } 1783 1189 1784 /** 1785 * Returns the number of related SearchIndexs. 1786 * 1787 * @param Criteria $criteria 1788 * @param boolean $distinct 1789 * @param Connection $con 1790 * @throws PropelException 1791 */ 1190 1792 1191 public function countSearchIndexs($criteria = null, $distinct = false, $con = null) 1793 1192 { 1794 // include the Peer class 1795 include_once 'model/om/BaseSearchIndexPeer.php'; 1193 include_once 'lib/model/om/BaseSearchIndexPeer.php'; 1796 1194 if ($criteria === null) { 1797 1195 $criteria = new Criteria(); … … 1807 1205 } 1808 1206 1809 /** 1810 * Method called to associate a SearchIndex object to this object 1811 * through the SearchIndex foreign key attribute 1812 * 1813 * @param SearchIndex $l SearchIndex 1814 * @return void 1815 * @throws PropelException 1816 */ 1207 1817 1208 public function addSearchIndex(SearchIndex $l) 1818 1209 { … … 1821 1212 } 1822 1213 1823 /** 1824 * Temporary storage of collReportQuestions to save a possible db hit in 1825 * the event objects are add to the collection, but the 1826 * complete collection is never requested. 1827 * @return void 1828 */ 1214 1829 1215 public function initReportQuestions() 1830 1216 { … … 1834 1220 } 1835 1221 1836 /** 1837 * If this collection has already been initialized with 1838 * an identical criteria, it returns the collection. 1839 * Otherwise if this Question has previously 1840 * been saved, it will retrieve related ReportQuestions from storage. 1841 * If this Question is new, it will return 1842 * an empty collection or the current collection, the criteria 1843 * is ignored on a new object. 1844 * 1845 * @param Connection $con 1846 * @param Criteria $criteria 1847 * @throws PropelException 1848 */ 1222 1849 1223 public function getReportQuestions($criteria = null, $con = null) 1850 1224 { 1851 // include the Peer class 1852 include_once 'model/om/BaseReportQuestionPeer.php'; 1225 include_once 'lib/model/om/BaseReportQuestionPeer.php'; 1853 1226 if ($criteria === null) { 1854 1227 $criteria = new Criteria(); … … 1870 1243 } 1871 1244 } else { 1872 // criteria has no effect for a new object 1873 if (!$this->isNew()) { 1874 // the following code is to determine if a new query is 1875 // called for. If the criteria is the same as the last 1876 // one, just return the collection. 1877 1245 if (!$this->isNew()) { 1246 1878 1247 1879 1248 $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); … … 1889 1258 } 1890 1259 1891 /** 1892 * Returns the number of related ReportQuestions. 1893 * 1894 * @param Criteria $criteria 1895 * @param boolean $distinct 1896 * @param Connection $con 1897 * @throws PropelException 1898 */ 1260 1899 1261 public function countReportQuestions($criteria = null, $distinct = false, $con = null) 1900 1262 { 1901 // include the Peer class 1902 include_once 'model/om/BaseReportQuestionPeer.php'; 1263 include_once 'lib/model/om/BaseReportQuestionPeer.php'; 1903 1264 if ($criteria === null) { 1904 1265 $criteria = new Criteria(); … … 1914 1275 } 1915 1276 1916 /** 1917 * Method called to associate a ReportQuestion object to this object 1918 * through the ReportQuestion foreign key attribute 1919 * 1920 * @param ReportQuestion $l ReportQuestion 1921 * @return void 1922 * @throws PropelException 1923 */ 1277 1924 1278 public function addReportQuestion(ReportQuestion $l) 1925 1279 { … … 1929 1283 1930 1284 1931 /** 1932 * If this collection has already been initialized with 1933 * an identical criteria, it returns the collection. 1934 * Otherwise if this Question is new, it will return 1935 * an empty collection; or if this Question has previously 1936 * been saved, it will retrieve related ReportQuestions from storage. 1937 * 1938 * This method is protected by default in order to keep the public 1939 * api reasonable. You can provide public methods for those you 1940 * actually need in Question. 1941 */ 1285 1942 1286 public function getReportQuestionsJoinUser($criteria = null, $con = null) 1943 1287 { 1944 // include the Peer class 1945 include_once 'model/om/BaseReportQuestionPeer.php'; 1288 include_once 'lib/model/om/BaseReportQuestionPeer.php'; 1946 1289 if ($criteria === null) { 1947 1290 $criteria = new Criteria(); … … 1962 1305 } 1963 1306 } else { 1964 // the following code is to determine if a new query is 1965 // called for. If the criteria is the same as the last 1966 // one, just return the collection. 1967 1307 1968 1308 $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); 1969 1309 … … 1977 1317 } 1978 1318 1979 } // BaseQuestion1319 } trunk/lib/model/om/BaseQuestionPeer.php
r74 r88 1 1 <?php 2 2 3 require_once 'propel/util/BasePeer.php'; 4 // The object class -- needed for instanceof checks in this class. 5 // actual class may be a subclass -- as returned by QuestionPeer::getOMClass() 6 include_once 'model/Question.php'; 7 8 /** 9 * Base static class for performing query and update operations on the 'ask_question' table. 10 * 11 * 12 * 13 * @package model.om 14 */ 3 15 4 abstract class BaseQuestionPeer { 16 5 17 /** the default database name for this class */6 18 7 const DATABASE_NAME = 'symfony'; 19 8 20 /** the table name for this class */9 21 10 const TABLE_NAME = 'ask_question'; 22 11 23 /** A class that can be returned by this peer. */24 const CLASS_DEFAULT = ' model.Question';25 26 /** The total number of columns. */12 13 const CLASS_DEFAULT = 'lib.model.Question'; 14 15 27 16 const NUM_COLUMNS = 10; 28 17 29 /** The number of lazy-loaded columns. */18 30 19 const NUM_LAZY_LOAD_COLUMNS = 0; 31 20 32 21 33 /** the column name for the ID field */22 34 23 const ID = 'ask_question.ID'; 35 24 36 /** the column name for the USER_ID field */25 37 26 const USER_ID = 'ask_question.USER_ID'; 38 27 39 /** the column name for the TITLE field */28 40 29 const TITLE = 'ask_question.TITLE'; 41 30 42 /** the column name for the STRIPPED_TITLE field */31 43 32 const STRIPPED_TITLE = 'ask_question.STRIPPED_TITLE'; 44 33 45 /** the column name for the BODY field */34 46 35 const BODY = 'ask_question.BODY'; 47 36 48 /** the column name for the HTML_BODY field */37 49 38 const HTML_BODY = 'ask_question.HTML_BODY'; 50 39 51 /** the column name for the INTERESTED_USERS field */40 52 41 const INTERESTED_USERS = 'ask_question.INTERESTED_USERS'; 53 42 54 /** the column name for the REPORTS field */43 55 44 const REPORTS = 'ask_question.REPORTS'; 56 45 57 /** the column name for the CREATED_AT field */46 58 47 const CREATED_AT = 'ask_question.CREATED_AT'; 59 48 60 /** the column name for the UPDATED_AT field */49 61 50 const UPDATED_AT = 'ask_question.UPDATED_AT'; 62 51 63 /** The PHP to DB Name Mapping */52 64 53 private static $phpNameMap = null; 65 54 66 55 67 /** 68 * holds an array of fieldnames 69 * 70 * first dimension keys are the type constants 71 * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' 72 */ 56 73 57 private static $fieldNames = array ( 74 58 BasePeer::TYPE_PHPNAME => array ('Id', 'UserId', 'Title', 'StrippedTitle', 'Body', 'HtmlBody', 'InterestedUsers', 'Reports', 'CreatedAt', 'UpdatedAt', ), … … 78 62 ); 79 63 80 /** 81 * holds an array of keys for quick access to the fieldnames array 82 * 83 * first dimension keys are the type constants 84 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 85 */ 64 86 65 private static $fieldKeys = array ( 87 66 BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'UserId' => 1, 'Title' => 2, 'StrippedTitle' => 3, 'Body' => 4, 'HtmlBody' => 5, 'InterestedUsers' => 6, 'Reports' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), … … 91 70 ); 92 71 93 /** 94 * @return MapBuilder the map builder for this peer 95 * @throws PropelException Any exceptions caught during processing will be 96 * rethrown wrapped into a PropelException. 97 */ 72 98 73 public static function getMapBuilder() 99 74 { 100 include_once 'model/map/QuestionMapBuilder.php'; 101 return BasePeer::getMapBuilder('model.map.QuestionMapBuilder'); 102 } 103 /** 104 * Gets a map (hash) of PHP names to DB column names. 105 * 106 * @return array The PHP to DB name map for this peer 107 * @throws PropelException Any exceptions caught during processing will be 108 * rethrown wrapped into a PropelException. 109 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. 110 */ 75 include_once 'lib/model/map/QuestionMapBuilder.php'; 76 return BasePeer::getMapBuilder('lib.model.map.QuestionMapBuilder'); 77 } 78 111 79 public static function getPhpNameMap() 112 80 { … … 122 90 return self::$phpNameMap; 123 91 } 124 /** 125 * Translates a fieldname to another type 126 * 127 * @param string $name field name 128 * @param string $fromType One of the class type constants TYPE_PHPNAME, 129 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 130 * @param string $toType One of the class type constants 131 * @return string translated name of the field. 132 */ 92 133 93 static public function translateFieldName($name, $fromType, $toType) 134 94 { … … 141 101 } 142 102 143 /** 144 * Returns an array of of field names. 145 * 146 * @param string $type The type of fieldnames to return: 147 * One of the class type constants TYPE_PHPNAME, 148 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 149 * @return array A list of field names 150 */ 103 151 104 152 105 static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) … … 158 111 } 159 112 160 /** 161 * Convenience method which changes table.column to alias.column. 162 * 163 * Using this method you can maintain SQL abstraction while using column aliases. 164 * <code> 165 * $c->addAlias("alias1", TablePeer::TABLE_NAME); 166 * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); 167 * </code> 168 * @param string $alias The alias for the current table. 169 * @param string $column The column name for current table. (i.e. QuestionPeer::COLUMN_NAME). 170 * @return string 171 */ 113 172 114 public static function alias($alias, $column) 173 115 { … … 175 117 } 176 118 177 /** 178 * Add all the columns needed to create a new object. 179 * 180 * Note: any columns that were marked with lazyLoad="true" in the 181 * XML schema will not be added to the select list and only loaded 182 * on demand. 183 * 184 * @param criteria object containing the columns to add. 185 * @throws PropelException Any exceptions caught during processing will be 186 * rethrown wrapped into a PropelException. 187 */ 119 188 120 public static function addSelectColumns(Criteria $criteria) 189 121 { … … 214 146 const COUNT_DISTINCT = 'COUNT(DISTINCT ask_question.ID)'; 215 147 216 /** 217 * Returns the number of rows matching criteria. 218 * 219 * @param Criteria $criteria 220 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 221 * @param Connection $con 222 * @return int Number of matching rows. 223 */ 148 224 149 public static function doCount(Criteria $criteria, $distinct = false, $con = null) 225 150 { 226 // we're going to modify criteria, so copy it first 227 $criteria = clone $criteria; 228 229 // clear out anything that might confuse the ORDER BY clause 230 $criteria->clearSelectColumns()->clearOrderByColumns(); 151 $criteria = clone $criteria; 152 153 $criteria->clearSelectColumns()->clearOrderByColumns(); 231 154 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 232 155 $criteria->addSelectColumn(QuestionPeer::COUNT_DISTINCT); … … 235 158 } 236 159 237 // just in case we're grouping: add those columns to the select statement 238 foreach($criteria->getGroupByColumns() as $column) 160 foreach($criteria->getGroupByColumns() as $column) 239 161 { 240 162 $criteria->addSelectColumn($column); … … 245 167 return $rs->getInt(1); 246 168 } else { 247 // no rows returned; we infer that means 0 matches. 248 return 0; 249 } 250 } 251 /** 252 * Method to select one object from the DB. 253 * 254 * @param Criteria $criteria object used to create the SELECT statement. 255 * @param Connection $con 256 * @return Question 257 * @throws PropelException Any exceptions caught during processing will be 258 * rethrown wrapped into a PropelException. 259 */ 169 return 0; 170 } 171 } 172 260 173 public static function doSelectOne(Criteria $criteria, $con = null) 261 174 { … … 268 181 return null; 269 182 } 270 /** 271 * Method to do selects. 272 * 273 * @param Criteria $criteria The Criteria object used to build the SELECT statement. 274 * @param Connection $con 275 * @return array Array of selected Objects 276 * @throws PropelException Any exceptions caught during processing will be 277 * rethrown wrapped into a PropelException. 278 */ 183 279 184 public static function doSelect(Criteria $criteria, $con = null) 280 185 { 281 186 return QuestionPeer::populateObjects(QuestionPeer::doSelectRS($criteria, $con)); 282 187 } 283 /** 284 * Prepares the Criteria object and uses the parent doSelect() 285 * method to get a ResultSet. 286 * 287 * Use this method directly if you want to just get the resultset 288 * (instead of an array of objects). 289 * 290 * @param Criteria $criteria The Criteria object used to build the SELECT statement. 291 * @param Connection $con the connection to use 292 * @throws PropelException Any exceptions caught during processing will be 293 * rethrown wrapped into a PropelException. 294 * @return ResultSet The resultset object with numerically-indexed fields. 295 * @see BasePeer::doSelect() 296 */ 188 297 189 public static function doSelectRS(Criteria $criteria, $con = null) 298 190 { … … 306 198 } 307 199 308 // Set the correct dbName 309 $criteria->setDbName(self::DATABASE_NAME); 310 311 // BasePeer returns a Creole ResultSet, set to return 312 // rows indexed numerically. 313 return BasePeer::doSelect($criteria, $con); 314 } 315 /** 316 * The returned array will contain objects of the default type or 317 * objects that inherit from the default. 318 * 319 * @throws PropelException Any exceptions caught during processing will be 320 * rethrown wrapped into a PropelException. 321 */ 200 $criteria->setDbName(self::DATABASE_NAME); 201 202 return BasePeer::doSelect($criteria, $con); 203 } 204 322 205 public static function populateObjects(ResultSet $rs) 323 206 { 324 207 $results = array(); 325 208 326 // set the class once to avoid overhead in the loop 327 $cls = QuestionPeer::getOMClass(); 209 $cls = QuestionPeer::getOMClass(); 328 210 $cls = Propel::import($cls); 329 // populate the object(s) 330 while($rs->next()) { 211 while($rs->next()) { 331 212 332 213 $obj = new $cls(); … … 338 219 } 339 220 340 /** 341 * Returns the number of rows matching criteria, joining the related User table 342 * 343 * @param Criteria $c 344 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 345 * @param Connection $con 346 * @return int Number of matching rows. 347 */ 221 348 222 public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) 349 223 { 350 // we're going to modify criteria, so copy it first 351 $criteria = clone $criteria; 224 $criteria = clone $criteria; 352 225 353 // clear out anything that might confuse the ORDER BY clause 354 $criteria->clearSelectColumns()->clearOrderByColumns(); 226 $criteria->clearSelectColumns()->clearOrderByColumns(); 355 227 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 356 228 $criteria->addSelectColumn(QuestionPeer::COUNT_DISTINCT); … … 359 231 } 360 232 361 // just in case we're grouping: add those columns to the select statement 362 foreach($criteria->getGroupByColumns() as $column) 233 foreach($criteria->getGroupByColumns() as $column) 363 234 { 364 235 $criteria->addSelectColumn($column); … … 371 242 return $rs->getInt(1); 372 243 } else { 373 // no rows returned; we infer that means 0 matches. 374 return 0; 375 } 376 } 377 378 379 /** 380 * Selects a collection of Question objects pre-filled with their User objects. 381 * 382 * @return array Array of Question objects. 383 * @throws PropelException Any exceptions caught during processing will be 384 * rethrown wrapped into a PropelException. 385 */ 244 return 0; 245 } 246 } 247 248 249 386 250 public static function doSelectJoinUser(Criteria $c, $con = null) 387 251 { 388 252 $c = clone $c; 389 253 390 // Set the correct dbName if it has not been overridden 391 if ($c->getDbName() == Propel::getDefaultDB()) { 254 if ($c->getDbName() == Propel::getDefaultDB()) { 392 255 $c->setDbName(self::DATABASE_NAME); 393 256 } … … 417 280 $newObject = true; 418 281 foreach($results as $temp_obj1) { 419 $temp_obj2 = $temp_obj1->getUser(); //CHECKME 420 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 282 $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 421 283 $newObject = false; 422 // e.g. $author->addBookRelatedByBookId() 423 $temp_obj2->addQuestion($obj1); //CHECKME 424 break; 284 $temp_obj2->addQuestion($obj1); break; 425 285 } 426 286 } 427 287 if ($newObject) { 428 288 $obj2->initQuestions(); 429 $obj2->addQuestion($obj1); //CHECKME 430 } 289 $obj2->addQuestion($obj1); } 431 290 $results[] = $obj1; 432 291 } … … 435 294 436 295 437 /** 438 * Returns the number of rows matching criteria, joining all related tables 439 * 440 * @param Criteria $c 441 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 442 * @param Connection $con 443 * @return int Number of matching rows. 444 */ 296 445 297 public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) 446 298 { 447 299 $criteria = clone $criteria; 448 300 449 // clear out anything that might confuse the ORDER BY clause 450 $criteria->clearSelectColumns()->clearOrderByColumns(); 301 $criteria->clearSelectColumns()->clearOrderByColumns(); 451 302 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 452 303 $criteria->addSelectColumn(QuestionPeer::COUNT_DISTINCT); … … 455 306 } 456 307 457 // just in case we're grouping: add those columns to the select statement 458 foreach($criteria->getGroupByColumns() as $column) 308 foreach($criteria->getGroupByColumns() as $column) 459 309 { 460 310 $criteria->addSelectColumn($column); … … 467 317 return $rs->getInt(1); 468 318 } else { 469 // no rows returned; we infer that means 0 matches. 470 return 0; 471 } 472 } 473 474 475 /** 476 * Selects a collection of Question objects pre-filled with all related objects. 477 * 478 * @return array Array of Question objects. 479 * @throws PropelException Any exceptions caught during processing will be 480 * rethrown wrapped into a PropelException. 481 */ 319 return 0; 320 } 321 } 322 323 324 482 325 public static function doSelectJoinAll(Criteria $c, $con = null) 483 326 { 484 327 $c = clone $c; 485 328 486 // Set the correct dbName if it has not been overridden 487 if ($c->getDbName() == Propel::getDefaultDB()) { 329 if ($c->getDbName() == Propel::getDefaultDB()) { 488 330 $c->setDbName(self::DATABASE_NAME); 489 331 } … … 510 352 511 353 512 // Add objects for joined User rows 513 354 514 355 $omClass = UserPeer::getOMClass(); 515 356 … … 522 363 for ($j=0, $resCount=count($results); $j < $resCount; $j++) { 523 364 $temp_obj1 = $results[$j]; 524 $temp_obj2 = $temp_obj1->getUser(); // CHECKME 525 if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 365 $temp_obj2 = $temp_obj1->getUser(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { 526 366 $newObject = false; 527 $temp_obj2->addQuestion($obj1); // CHECKME 528 break; 367 $temp_obj2->addQuestion($obj1); break; 529 368 } 530 369 } … … 540 379 } 541 380 542 /** 543 * Returns the TableMap related to this peer. 544 * This method is not needed for general use but a specific application could have a need. 545 * @return TableMap 546 * @throws PropelException Any exceptions caught during processing will be 547 * rethrown wrapped into a PropelException. 548 */ 381 549 382 public static function getTableMap() 550 383 { … … 552 385 } 553 386 554 /** 555 * The class that the Peer will make instances of. 556 * 557 * This uses a dot-path notation which is tranalted into a path 558 * relative to a location on the PHP include_path. 559 * (e.g. path.to.MyClass -> 'path/to/MyClass.php') 560 * 561 * @return string path.to.ClassName 562 */ 387 563 388 public static function getOMClass() 564 389 { … … 566 391 } 567 392 568 /** 569 * Method perform an INSERT on the database, given a Question or Criteria object. 570 * 571 * @param mixed $values Criteria or Question object containing data that is used to create the INSERT statement. 572 * @param Connection $con the connection to use 573 * @return mixed The new primary key. 574 * @throws PropelException Any exceptions caught during processing will be 575 * rethrown wrapped into a PropelException. 576 */ 393 577 394 public static function doInsert($values, $con = null) 578 395 { … … 582 399 583 400 if ($values instanceof Criteria) { 584 $criteria = clone $values; // rename for clarity 585 } else { 586 $criteria = $values->buildCriteria(); // build Criteria from Question object 587 } 588 589 $criteria->remove(QuestionPeer::ID); // remove pkey col since this table uses auto-increment 590 591 592 // Set the correct dbName 593 $criteria->setDbName(self::DATABASE_NAME); 401 $criteria = clone $values; } else { 402 $criteria = $values->buildCriteria(); } 403 404 $criteria->remove(QuestionPeer::ID); 405 406 $criteria->setDbName(self::DATABASE_NAME); 594 407 595 408 try { 596 // use transaction because $criteria could contain info 597 // for more than one table (I guess, conceivably) 598 $con->begin(); 409 $con->begin(); 599 410 $pk = BasePeer::doInsert($criteria, $con); 600 411 $con->commit(); … … 607 418 } 608 419 609 /** 610 * Method perform an UPDATE on the database, given a Question or Criteria object. 611 * 612 * @param mixed $values Criteria or Question object containing data that is used to create the UPDATE statement. 613 * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). 614 * @return int The number of affected rows (if supported by underlying database driver). 615 * @throws PropelException Any exceptions caught during processing will be 616 * rethrown wrapped into a PropelException. 617 */ 420 618 421 public static function doUpdate($values, $con = null) 619 422 { … … 625 428 626 429 if ($values instanceof Criteria) { 627 $criteria = clone $values; // rename for clarity 628 430 $criteria = clone $values; 629 431 $comparison = $criteria->getComparison(QuestionPeer::ID); 630 432 $selectCriteria->add(QuestionPeer::ID, $criteria->remove(QuestionPeer::ID), $comparison); 631 433 632 } else { // $values is Question object 633 $criteria = $values->buildCriteria(); // gets full criteria 634 $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) 635 } 636 637 // set the correct dbName 638 $criteria->setDbName(self::DATABASE_NAME); 434 } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); } 435 436 $criteria->setDbName(self::DATABASE_NAME); 639 437 640 438 return BasePeer::doUpdate($selectCriteria, $criteria, $con); 641 439 } 642 440 643 /** 644 * Method to DELETE all rows from the ask_question table. 645 * 646 * @return int The number of affected rows (if supported by underlying database driver). 647 */ 441 648 442 public static function doDeleteAll($con = null) 649 443 { … … 651 445 $con = Propel::getConnection(self::DATABASE_NAME); 652 446 } 653 $affectedRows = 0; // initialize var to track total num of affected rows 654 try { 655 // use transaction because $criteria could contain info 656 // for more than one table or we could emulating ON DELETE CASCADE, etc. 657 $con->begin(); 447 $affectedRows = 0; try { 448 $con->begin(); 658 449 $affectedRows += BasePeer::doDeleteAll(QuestionPeer::TABLE_NAME, $con); 659 450 $con->commit(); … … 665 456 } 666 457 667 /** 668 * Method perform a DELETE on the database, given a Question or Criteria object OR a primary key value. 669 * 670 * @param mixed $values Criteria or Question object or primary key or array of primary keys 671 * which is used to create the DELETE statement 672 * @param Connection $con the connection to use 673 * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows 674 * if supported by native driver or if emulated using Propel. 675 * @throws PropelException Any exceptions caught during processing will be 676 * rethrown wrapped into a PropelException. 677 */ 458 678 459 public static function doDelete($values, $con = null) 679 460 { … … 683 464 684 465 if ($values instanceof Criteria) { 685 $criteria = clone $values; // rename for clarity 686 } elseif ($values instanceof Question) { 466 $criteria = clone $values; } elseif ($values instanceof Question) { 687 467 688 468 $criteria = $values->buildPkeyCriteria(); 689 469 } else { 690 // it must be the primary key 691 $criteria = new Criteria(self::DATABASE_NAME); 470 $criteria = new Criteria(self::DATABASE_NAME); 692 471 $criteria->add(QuestionPeer::ID, (array) $values, Criteria::IN); 693 472 } 694 473 695 // Set the correct dbName 696 $criteria->setDbName(self::DATABASE_NAME); 697 698 $affectedRows = 0; // initialize var to track total num of affected rows 699 474 $criteria->setDbName(self::DATABASE_NAME); 475 476 $affectedRows = 0; 700 477 try { 701 // use transaction because $criteria could contain info 702 // for more than one table or we could emulating ON DELETE CASCADE, etc. 703 $con->begin(); 478 $con->begin(); 704 479 705 480 $affectedRows += BasePeer::doDelete($criteria, $con); … … 712 487 } 713 488 714 /** 715 * Validates all modified columns of given Question object. 716 * If parameter $columns is either a single column name or an array of column names 717 * than only those columns are validated. 718 * 719 * NOTICE: This does not apply to primary or foreign keys for now. 720 * 721 * @param Question $obj The object to validate. 722 * @param mixed $cols Column name or array of column names. 723 * 724 * @return mixed TRUE if all columns are valid or the error message of the first invalid column. 725 */ 489 726 490 public static function doValidate(Question $obj, $cols = null) 727 491 { … … 758 522 } 759 523 760 /** 761 * Retrieve a single object by pkey. 762 * 763 * @param mixed $pk the primary key. 764 * @param Connection $con the connection to use 765 * @return Question 766 */ 524 767 525 public static function retrieveByPK($pk, $con = null) 768 526 { … … 777 535 778 536 $v = QuestionPeer::doSelect($criteria, $con); 779 return !empty($v) > 0 ? $v[0] : null; 780 } 781 782 /** 783 * Retrieve multiple objects by pkey. 784 * 785 * @param array $pks List of primary keys 786 * @param Connection $con the connection to use 787 * @throws PropelException Any exceptions caught during processing will be 788 * rethrown wrapped into a PropelException. 789 */ 537 538 return !empty($v) > 0 ? $v[0] : null; 539 } 540 541 790 542 public static function retrieveByPKs($pks, $con = null) 791 543 { … … 805 557 } 806 558 807 } // BaseQuestionPeer 808 809 // static code to register the map builder for this Peer with the main Propel class 559 } 810 560 if (Propel::isInit()) { 811 // the MapBuilder classes register themselves with Propel during initialization 812 // so we need to load them here. 813 try { 561 try { 814 562 BaseQuestionPeer::getMapBuilder(); 815 563 } catch (Exception $e) { … … 817 565 } 818 566 } else { 819 // even if Propel is not yet initialized, the map builder class can be registered 820 // now and then it will be loaded when Propel initializes. 821 require_once 'model/map/QuestionMapBuilder.php'; 822 Propel::registerMapBuilder('model.map.QuestionMapBuilder'); 567 require_once 'lib/model/map/QuestionMapBuilder.php'; 568 Propel::registerMapBuilder('lib.model.map.QuestionMapBuilder'); 823 569 } trunk/lib/model/om/BaseQuestionTag.php
r74 r88 1 1 <?php 2 2 3 require_once 'propel/om/BaseObject.php'; 4 5 require_once 'propel/om/Persistent.php'; 6 7 8 include_once 'propel/util/Criteria.php'; 9 10 include_once 'model/QuestionTagPeer.php'; 11 12 /** 13 * Base class that represents a row from the 'ask_question_tag' table. 14 * 15 * 16 * 17 * @package model.om 18 */ 3 19 4 abstract class BaseQuestionTag extends BaseObject implements Persistent { 20 5 21 6 22 /** 23 * The Peer class. 24 * Instance provides a convenient way of calling static methods on a class 25 * that calling code may not be able to identify. 26 * @var QuestionTagPeer 27 */ 7 8 const DATABASE_NAME = 'symfony'; 9 10 28 11 protected static $peer; 29 12 30 13 31 /** 32 * The value for the question_id field. 33 * @var int 34 */ 14 35 15 protected $question_id; 36 16 37 17 38 /** 39 * The value for the user_id field. 40 * @var int 41 */ 18 42 19 protected $user_id; 43 20 44 21 45 /** 46 * The value for the created_at field. 47 * @var int 48 */ 22 49 23 protected $created_at; 50 24 51 25 52 /** 53 * The value for the tag field. 54 * @var string 55 */ 26 56 27 protected $tag; 57 28 58 29 59 /** 60 * The value for the normalized_tag field. 61 * @var string 62 */ 30 63 31 protected $normalized_tag; 64 32 65 /** 66 * @var Question 67 */ 33 68 34 protected $aQuestion; 69 35 70 /** 71 * @var User 72 */ 36 73 37 protected $aUser; 74 38 75 /** 76 * Flag to prevent endless save loop, if this object is referenced 77 * by another object which falls in this transaction. 78 * @var boolean 79 */ 39 80 40 protected $alreadyInSave = false; 81 41 82 /** 83 * Flag to prevent endless validation loop, if this object is referenced 84 * by another object which falls in this transaction. 85 * @var boolean 86 */ 42 87 43 protected $alreadyInValidation = false; 88 44 89 /** 90 * Get the [question_id] column value. 91 * 92 * @return int 93 */ 45 94 46 public function getQuestionId() 95 47 { … … 98 50 } 99 51 100 /** 101 * Get the [user_id] column value. 102 * 103 * @return int 104 */ 52 105 53 public function getUserId() 106 54 { … … 109 57 } 110 58 111 /** 112 * Get the [optionally formatted] [created_at] column value. 113 * 114 * @param string $format The date/time format string (either date()-style or strftime()-style). 115 * If format is NULL, then the integer unix timestamp will be returned. 116 * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). 117 * @throws PropelException - if unable to convert the date/time to timestamp. 118 */ 59 119 60 public function getCreatedAt($format = 'Y-m-d H:i:s') 120 61 { … … 123 64 return null; 124 65 } elseif (!is_int($this->created_at)) { 125 // a non-timestamp value was set externally, so we convert it 126 $ts = strtotime($this->created_at); 127 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 128 throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); 66 $ts = strtotime($this->created_at); 67 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); 129 68 } 130 69 } else { … … 140 79 } 141 80 142 /** 143 * Get the [tag] column value. 144 * 145 * @return string 146 */ 81 147 82 public function getTag() 148 83 { … … 151 86 } 152 87 153 /** 154 * Get the [normalized_tag] column value. 155 * 156 * @return string 157 */ 88 158 89 public function getNormalizedTag() 159 90 { … … 162 93 } 163 94 164 /** 165 * Set the value of [question_id] column. 166 * 167 * @param int $v new value 168 * @return void 169 */ 95 170 96 public function setQuestionId($v) 171 97 { … … 178 104 if ($this->aQuestion !== null && $this->aQuestion->getId() !== $v) { 179 105 $this->aQuestion = null; 180 } 181 182 } // setQuestionId() 183 184 /** 185 * Set the value of [user_id] column. 186 * 187 * @param int $v new value 188 * @return void 189 */ 106 } 107 108 } 109 190 110 public function setUserId($v) 191 111 { … … 198 118 if ($this->aUser !== null && $this->aUser->getId() !== $v) { 199 119 $this->aUser = null; 200 } 201 202 } // setUserId() 203 204 /** 205 * Set the value of [created_at] column. 206 * 207 * @param int $v new value 208 * @return void 209 */ 120 } 121 122 } 123 210 124 public function setCreatedAt($v) 211 125 { … … 213 127 if ($v !== null && !is_int($v)) { 214 128 $ts = strtotime($v); 215 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 216 throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); 129 if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); 217 130 } 218 131 } else { … … 224 137 } 225 138 226 } // setCreatedAt() 227 228 /** 229 * Set the value of [tag] column. 230 * 231 * @param string $v new value 232 * @return void 233 */ 139 } 140 234 141 public function setTag($v) 235 142 { … … 240 147 } 241 148 242 } // setTag() 243 244 /** 245 * Set the value of [normalized_tag] column. 246 * 247 * @param string $v new value 248 * @return void 249 */ 149 } 150 250 151 public function setNormalizedTag($v) 251 152 { … … 256 157 } 257 158 258 } // setNormalizedTag() 259 260 /** 261 * Hydrates (populates) the object variables with values from the database resultset. 262 * 263 * An offset (1-based "start column") is specified so that objects can be hydrated 264 * with a subset of the columns in the resultset rows. This is needed, for example, 265 * for results of JOIN queries where the resultset row includes columns from two or 266 * more tables. 267 * 268 * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. 269 * @param int $startcol 1-based offset column which indicates which restultset column to start with. 270 * @return int next starting column 271 * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. 272 */ 159 } 160 273 161 public function hydrate(ResultSet $rs, $startcol = 1) 274 162 { … … 289 177 $this->setNew(false); 290 178 291 // FIXME - using NUM_COLUMNS may be clearer. 292 return $startcol + 5; // 5 = QuestionTagPeer::NUM_COLUMNS - QuestionTagPeer::NUM_LAZY_LOAD_COLUMNS). 293 179 return $startcol + 5; 294 180 } catch (Exception $e) { 295 181 throw new PropelException("Error populating QuestionTag object", $e); … … 297 183 } 298 184 299 /** 300 * Removes this object from datastore and sets delete attribute. 301 * 302 * @param Connection $con 303 * @return void 304 * @throws PropelException 305 * @see BaseObject::setDeleted() 306 * @see BaseObject::isDeleted() 307 */ 185 308 186 public function delete($con = null) 309 187 { … … 327 205 } 328 206 329 /** 330 * Stores the object in the database. If the object is new, 331 * it inserts it; otherwise an update is performed. This method 332 * wraps the doSave() worker method in a transaction. 333 * 334 * @param Connection $con 335 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. 336 * @throws PropelException 337 * @see doSave() 338 */ 207 339 208 public function save($con = null) 340 209 { 341 if ($this->isNew() )210 if ($this->isNew() && !$this->isColumnModified(QuestionTagPeer::CREATED_AT)) 342 211 { 343 212 $this->setCreatedAt(time()); … … 351 220 $con = Propel::getConnection(QuestionTagPeer::DATABASE_NAME); 352 221 } 353 222 354 223 try { 355 224 $con->begin(); … … 363 232 } 364 233 365 /** 366 * Stores the object in the database. 367 * 368 * If the object is new, it inserts it; otherwise an update is performed. 369 * All related objects are also updated in this method. 370 * 371 * @param Connection $con 372 * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. 373 * @throws PropelException 374 * @see save() 375 */ 234 376 235 protected function doSave($con) 377 236 { 378 $affectedRows = 0; // initialize var to track total num of affected rows 379 if (!$this->alreadyInSave) { 237 $affectedRows = 0; if (!$this->alreadyInSave) { 380 238 $this->alreadyInSave = true; 381 239 382 240 383 // We call the save method on the following object(s) if they 384 // were passed to this object by their coresponding set 385 // method. This object relates to these object(s) by a 386 // foreign key reference. 387 241 388 242 if ($this->aQuestion !== null) { 389 243 if ($this->aQuestion->isModified()) { … … 399 253 $this->setUser($this->aUser); 400 254 } 401 402 403 // If this object has been modified, then save it to the database. 404 if ($this->isModified()) { 255 256 257 if ($this->isModified()) { 405 258 if ($this->isNew()) { 406 259 $pk = QuestionTagPeer::doInsert($this, $con); 407 $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which 408 // should always be true here (even though technically 409 // BasePeer::doInsert() can insert multiple rows). 410 260 $affectedRows += 1; 411 261 $this->setNew(false); 412 262 } else { 413 263 $affectedRows += QuestionTagPeer::doUpdate($this, $con); 414 264 } 415 $this->resetModified(); // [HL] After being saved an object is no longer 'modified' 416 } 265 $this->resetModified(); } 417 266 418 267 $this->alreadyInSave = false; 419 268 } 420 269 return $affectedRows; 421 } // doSave() 422 423 /** 424 * Array of ValidationFailed objects. 425 * @var array ValidationFailed[] 426 */ 270 } 271 427 272 protected $validationFailures = array(); 428 273 429 /** 430 * Gets any ValidationFailed objects that resulted from last call to validate(). 431 * 432 * 433 * @return array ValidationFailed[] 434 * @see validate() 435 */ 274 436 275 public function getValidationFailures() 437 276 { … … 439 278 } 440 279 441 /** 442 * Validates the objects modified field values and all objects related to this table. 443 * 444 * If $columns is either a column name or an array of column names 445 * only those columns are validated. 446 * 447 * @param mixed $columns Column name or an array of column names. 448 * @return boolean Whether all columns pass validation. 449 * @see doValidate() 450 * @see getValidationFailures() 451 */ 280 452 281 public function validate($columns = null) 453 282 { … … 462 291 } 463 292 464 /** 465 * This function performs the validation work for complex object models. 466 * 467 * In addition to checking the current object, all related objects will 468 * also be validated. If all pass then <code>true</code> is returned; otherwise 469 * an aggreagated array of ValidationFailed objects will be returned. 470 * 471 * @param array $columns Array of column names to validate. 472 * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 473 */ 293 474 294 protected function doValidate($columns = null) 475 295 { … … 481 301 482 302 483 // We call the validate method on the following object(s) if they 484 // were passed to this object by their coresponding set 485 // method. This object relates to these object(s) by a 486 // foreign key reference. 487 303 488 304 if ($this->aQuestion !== null) { 489 305 if (!$this->aQuestion->validate($columns)) { … … 511 327 } 512 328 513 /** 514 * Retrieves a field from the object by name passed in as a string. 515 * 516 * @param string $name name 517 * @param string $type The type of fieldname the $name is of: 518 * one of the class type constants TYPE_PHPNAME, 519 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 520 * @return mixed Value of field. 521 */ 329 522 330 public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 523 331 { … … 526 334 } 527 335 528 /** 529 * Retrieves a field from the object by Position as specified in the xml schema. 530 * Zero-based. 531 * 532 * @param int $pos position in xml schema 533 * @return mixed Value of field at $pos 534 */ 336 535 337 public function getByPosition($pos) 536 338 { … … 554 356 return null; 555 357 break; 556 } // switch() 557 } 558 559 /** 560 * Exports the object as an array. 561 * 562 * You can specify the key type of the array by passing one of the class 563 * type constants. 564 * 565 * @param string $keyType One of the class type constants TYPE_PHPNAME, 566 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 567 * @return an associative array containing the field names (as keys) and field values 568 */ 358 } } 359 360 569 361 public function toArray($keyType = BasePeer::TYPE_PHPNAME) 570 362 { … … 580 372 } 581 373 582 /** 583 * Sets a field from the object by name passed in as a string. 584 * 585 * @param string $name peer name 586 * @param mixed $value field value 587 * @param string $type The type of fieldname the $name is of: 588 * one of the class type constants TYPE_PHPNAME, 589 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 590 * @return void 591 */ 374 592 375 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 593 376 { … … 596 379 } 597 380 598 /** 599 * Sets a field from the object by Position as specified in the xml schema. 600 * Zero-based. 601 * 602 * @param int $pos position in xml schema 603 * @param mixed $value field value 604 * @return void 605 */ 381 606 382 public function setByPosition($pos, $value) 607 383 { … … 622 398 $this->setNormalizedTag($value); 623 399 break; 624 } // switch() 625 } 626 627 /** 628 * Populates the object using an array. 629 * 630 * This is particularly useful when populating an object from one of the 631 * request arrays (e.g. $_POST). This method goes through the column 632 * names, checking to see whether a matching key exists in populated 633 * array. If so the setByName() method is called for that column. 634 * 635 * You can specify the key type of the array by additionally passing one 636 * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, 637 * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') 638 * 639 * @param array $arr An array to populate the object from. 640 * @param string $keyType The type of keys the array uses. 641 * @return void 642 */ 400 } } 401 402 643 403 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) 644 404 { … … 652 412 } 653 413 654 /** 655 * Build a Criteria object containing the values of all modified columns in this object. 656 * 657 * @return Criteria The Criteria object containing all modified values. 658 */ 414 659 415 public function buildCriteria() 660 416 { … … 670 426 } 671 427 672 /** 673 * Builds a Criteria object containing the primary key for this object. 674 * 675 * Unlike buildCriteria() this method includes the primary key values regardless 676 * of whether or not they have been modified. 677 * 678 * @return Criteria The Criteria object containing value(s) for primary key(s). 679 */ 428 680 429 public function buildPkeyCriteria() 681 430 { … … 689 438 } 690 439 691 /** 692 * Returns the composite primary key for this object. 693 * The array elements will be in same order as specified in XML. 694 * @return array 695 */ 440 696 441 public function getPrimaryKey() 697 442 { … … 707 452 } 708 453 709 /** 710 * Set the [composite] primary key. 711 * 712 * @param array $keys The elements of the composite key (order must match the order in XML file). 713 * @return void 714 */ 454 715 455 public function setPrimaryKey($keys) 716 456 { … … 724 464 } 725 465 726 /** 727 * Sets contents of passed object to values from current object. 728 * 729 * If desired, this method can also make copies of all associated (fkey referrers) 730 * objects. 731 * 732 * @param object $copyObj An object of QuestionTag (or compatible) type. 733 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 734 * @throws PropelException 735 */ 466 736 467 public function copyInto($copyObj, $deepCopy = false) 737 468 { … … 744 475 $copyObj->setNew(true); 745 476 746 $copyObj->setQuestionId(NULL); // this is a pkey column, so set to default value 747 748 $copyObj->setUserId(NULL); // this is a pkey column, so set to default value 749 750 $copyObj->setNormalizedTag(NULL); // this is a pkey column, so set to default value 751 752 } 753 754 /** 755 * Makes a copy of this object that will be inserted as a new row in table when saved. 756 * It creates a new object filling in the simple attributes, but skipping any primary 757 * keys that are defined for the table. 758 * 759 * If desired, this method can also make copies of all associated (fkey referrers) 760 * objects. 761 * 762 * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 763 * @return QuestionTag Clone of current object. 764 * @throws PropelException 765 */ 477 $copyObj->setQuestionId(NULL); 478 $copyObj->setUserId(NULL); 479 $copyObj->setNormalizedTag(NULL); 480 } 481 482 766 483 public function copy($deepCopy = false) 767 484 { 768 // we use get_class(), because this might be a subclass 769 $clazz = get_class($this); 485 $clazz = get_class($this); 770 486 $copyObj = new $clazz(); 771 487 $this->copyInto($copyObj, $deepCopy); … … 773 489 } 774 490 775 /** 776 * Returns a peer instance associated with this om. 777 * 778 * Since Peer classes are not to have any instance attributes, this method returns the 779 * same instance for all member of this class. The method could therefore 780 * be static, but this would prevent one from overriding the behavior. 781 * 782 * @return QuestionTagPeer 783 */ 491 784 492 public function getPeer() 785 493 { … … 790 498 } 791 499 792 /** 793 * Declares an association between this object and a Question object. 794 * 795 * @param Question $v 796 * @return void 797 * @throws PropelException 798 */ 500 799 501 public function setQuestion($v) 800 502 { … … 812 514 813 515 814 /** 815 * Get the associated Question object 816 * 817 * @param Connection Optional Connection object. 818 * @return Question The associated Question object. 819 * @throws PropelException 820 */ 516 821 517 public function getQuestion($con = null) 822 518 { 823 // include the related Peer class 824 include_once 'model/om/BaseQuestionPeer.php'; 519 include_once 'lib/model/om/BaseQuestionPeer.php'; 825 520 826 521 if ($this->aQuestion === null && ($this->question_id !== null)) { 827 522 828 523 $this->aQuestion = QuestionPeer::retrieveByPK($this->question_id, $con); 829 830 /* The following can be used instead of the line above to 831 guarantee the related object contains a reference 832 to this object, but this level of coupling 833 may be undesirable in many circumstances. 834 As it can lead to a db query with many results that may 835 never be used. 836 $obj = QuestionPeer::retrieveByPK($this->question_id, $con); 837 $obj->addQuestions($this); 838 */ 524 525 839 526 } 840 527 return $this->aQuestion; 841 528 } 842 529 843 /** 844 * Declares an association between this object and a User object. 845 * 846 * @param User $v 847 * @return void 848 * @throws PropelException 849 */ 530 850 531 public function setUser($v) 851 532 { … … 863 544 864 545 865 /** 866 * Get the associated User object 867 * 868 * @param Connection Optional Connection object. 869 * @return User The associated User object. 870 * @throws PropelException 871 */ 546 872 547 public function getUser($con = null) 873 548 { 874 // include the related Peer class 875 include_once 'model/om/BaseUserPeer.php'; 549 include_once 'lib/model/om/BaseUserPeer.php'; 876 550 877 551 if ($this->aUser === null && ($this->user_id !== null)) { 878 552 879 553 $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); 880 881 /* The following can be used instead of the line above to 882 guarantee the related object contains a reference 883 to this object, but this level of coupling 884 may be undesirable in many circumstances. 885 As it can lead to a db query with many results that may 886 never be used. 887 $obj = UserPeer::retrieveByPK($this->user_id, $con); 888 $obj->addUsers($this); 889 */ 554 555 890 556 } 891 557 return $this->aUser; 892 558 } 893 559 894 } // BaseQuestionTag560 } trunk/lib/model/om/BaseQuestionTagPeer.php
r74 r88 1 1 <?php 2 2 3 require_once 'propel/util/BasePeer.php'; 4 // The object class -- needed for instanceof checks in this class. 5 // actual class may be a subclass -- as returned by QuestionTagPeer::getOMClass() 6 include_once 'model/QuestionTag.php'; 7 8 /** 9 * Base static class for performing query and update operations on the 'ask_question_tag' table. 10 * 11 * 12 * 13 * @package model.om 14 */ 3 15 4 abstract class BaseQuestionTagPeer { 16 5 17 /** the default database name for this class */6 18 7 const DATABASE_NAME = 'symfony'; 19 8 20 /** the table name for this class */9 21 10 const TABLE_NAME = 'ask_question_tag'; 22 11 23 /** A class that can be returned by this peer. */24 const CLASS_DEFAULT = ' model.QuestionTag';25 26 /** The total number of columns. */12 13 const CLASS_DEFAULT = 'lib.model.QuestionTag'; 14 15 27 16 const NUM_COLUMNS = 5; 28 17 29 /** The number of lazy-loaded columns. */18 30 19 const NUM_LAZY_LOAD_COLUMNS = 0; 31 20 32 21 33 /** the column name for the QUESTION_ID field */22 34 23 const QUESTION_ID = 'ask_question_tag.QUESTION_ID'; 35 24 36 /** the column name for the USER_ID field */25 37 26 const USER_ID = 'ask_question_tag.USER_ID'; 38 27 39 /** the column name for the CREATED_AT field */28 40 29 const CREATED_AT = 'ask_question_tag.CREATED_AT'; 41 30 42 /** the column name for the TAG field */31 43 32 const TAG = 'ask_question_tag.TAG'; 44 33 45 /** the column name for the NORMALIZED_TAG field */34 46 35 const NORMALIZED_TAG = 'ask_question_tag.NORMALIZED_TAG'; 47 36 48 /** The PHP to DB Name Mapping */37 49 38 private static $phpNameMap = null; 50 39 51 40 52 /** 53 * holds an array of fieldnames 54 * 55 * first dimension keys are the type constants 56 * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' 57 */ 41 58 42 private static $fieldNames = array ( 59 43 BasePeer::TYPE_PHPNAME => array ('QuestionId', 'UserId', 'CreatedAt', 'Tag', 'NormalizedTag', ), … … 63 47 ); 64 48 65 /** 66 * holds an array of keys for quick access to the fieldnames array 67 * 68 * first dimension keys are the type constants 69 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 70 */ 49 71 50 private static $fieldKeys = array ( 72 51 BasePeer::TYPE_PHPNAME => array ('QuestionId' => 0, 'UserId' => 1, 'CreatedAt' => 2, 'Tag' => 3, 'NormalizedTag' => 4, ), … … 76 55 ); 77 56 78 /** 79 * @return MapBuilder the map builder for this peer 80 * @throws PropelException Any exceptions caught during processing will be 81 * rethrown wrapped into a PropelException. 82 */ 57 83 58 public static function getMapBuilder() 84 59 { 85 include_once 'model/map/QuestionTagMapBuilder.php'; 86 return BasePeer::getMapBuilder('model.map.QuestionTagMapBuilder'); 87 } 88 /** 89 * Gets a map (hash) of PHP names to DB column names. 90 * 91 * @return array The PHP to DB name map for this peer 92 * @throws PropelException Any exceptions caught during processing will be 93 * rethrown wrapped into a PropelException. 94 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. 95 */ 60 include_once 'lib/model/map/QuestionTagMapBuilder.php'; 61 return BasePeer::getMapBuilder('lib.model.map.QuestionTagMapBuilder'); 62 } 63 96 64 public static function getPhpNameMap() 97 65 { … … 107 75 return self::$phpNameMap; 108 76 } 109 /** 110 * Translates a fieldname to another type 111 * 112 * @param string $name field name 113 * @param string $fromType One of the class type constants TYPE_PHPNAME, 114 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 115 * @param string $toType One of the class type constants 116 * @return string translated name of the field. 117 */ 77 118 78 static public function translateFieldName($name, $fromType, $toType) 119 79 { … … 126 86 } 127 87 128 /** 129 * Returns an array of of field names. 130 * 131 * @param string $type The type of fieldnames to return: 132 * One of the class type constants TYPE_PHPNAME, 133 * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM 134 * @return array A list of field names 135 */ 88 136 89 137 90 static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) … … 143 96 } 144 97 145 /** 146 * Convenience method which changes table.column to alias.column. 147 * 148 * Using this method you can maintain SQL abstraction while using column aliases. 149 * <code> 150 * $c->addAlias("alias1", TablePeer::TABLE_NAME); 151 * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); 152 * </code> 153 * @param string $alias The alias for the current table. 154 * @param string $column The column name for current table. (i.e. QuestionTagPeer::COLUMN_NAME). 155 * @return string 156 */ 98 157 99 public static function alias($alias, $column) 158 100 { … … 160 102 } 161 103 162 /** 163 * Add all the columns needed to create a new object. 164 * 165 * Note: any columns that were marked with lazyLoad="true" in the 166 * XML schema will not be added to the select list and only loaded 167 * on demand. 168 * 169 * @param criteria object containing the columns to add. 170 * @throws PropelException Any exceptions caught during processing will be 171 * rethrown wrapped into a PropelException. 172 */ 104 173 105 public static function addSelectColumns(Criteria $criteria) 174 106 { … … 189 121 const COUNT_DISTINCT = 'COUNT(DISTINCT ask_question_tag.QUESTION_ID)'; 190 122 191 /** 192 * Returns the number of rows matching criteria. 193 * 194 * @param Criteria $criteria 195 * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). 196 * @param Connection $con 197 * @return int Number of matching rows. 198 */ 123 199 124 public static function doCount(Criteria $criteria, $distinct = false, $con = null) 200 125 { 201 // we're going to modify criteria, so copy it first 202 $criteria = clone $criteria; 203 204 // clear out anything that might confuse the ORDER BY clause 205 $criteria->clearSelectColumns()->clearOrderByColumns(); 126 $criteria = clone $criteria; 127 128 $criteria->clearSelectColumns()->clearOrderByColumns(); 206 129 if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { 207 130 $criteria->addSelectColumn(QuestionTagPeer::COUNT_DISTINCT); … … 210 133 } 211 134 212 // just in case we're grouping: add those columns to the select statement 213 foreach($criteria->getGroupByColumns() as $column) 135 foreach($criteria->getGroupByColumns() as $column) 214 136 { 215 137 $criteria->addSelectColumn($column); … … 220 142 return $rs->getInt(1); 221 143 } else { 222 // no rows returned; we infer that means 0 matches. 223 return 0; 224 } 225 } 226 /** 227 * Method to select one object from the DB. 228 * 229 * @param Criteria $criteria object used to create the SELECT statement. 230 * @param Connection $con 231 * @return QuestionTag 232 * @throws PropelException Any exceptions caught during processing will be 233 * rethrown wrapped into a PropelException. 234 */ 144 return 0; 145 } 146 } 147 235 148 public static function doSelectOne(Criteria $criteria, $con = null) 236 149 { … … 243 156 return null; 244 157 } 245 /** 246 * Method to do selects. 247 * 248 * @param Criteria $criteria The Criteria object used to build the SELECT statement. 249 * @param Connection $con 250 * @return array Array of selected Objects 251 * @throws PropelException Any exceptions caught during processing will be 252 * rethrown wrapped into a PropelException. 253 */ 158 254 159 public static function doSelect(Criteria $criteria, $con = null) 255 160 { 256 161 return QuestionTagPeer::populateObjects(QuestionTagPeer::doSelectRS($criteria, $con)); 257 162 } 258 /** 259 * Prepares the Criteria object and uses the parent doSelect() 260 * method to get a ResultSet. 261 * 262 * Use this method directly if you want to just get the resultset 263 * (instead of an array of objects). 264 * 265 * @param Criteria $criteria The Criteria object used to build the SELECT statement. 266 * @param Connection $con the connection to use 267 * @throws PropelException Any exceptions caught during processing will be 268 * rethrown wrapped into a PropelException. 269 * @return ResultSet The resultset object with numerically-indexed fields. 270 * @see BasePeer::doSelect() 271 */ 163 272 164 public static function doSelectRS(Criteria $criteria, $con = null) 273 165 { … … 281 173 } 282 174 283 // Set the correct dbName 284 $criteria->setDbName(self::DATABASE_NAME); 285 286 // BasePeer returns a Creole ResultSet, set to return 287 // rows indexed numerically. 288 return BasePeer::doSelect($criteria, $con); 289 } 290 /** 291 * The returned array will contain objects of the default type or 292 * objects that inherit from the default. 293 * 294 * @throws PropelException Any exceptions caught during processing will be 295 * rethrown wrapped into a PropelException. 296 */ 175 $criteria->setDbName(self::DATABASE_NAME); 176 177 return BasePeer::doSelect($criteria, $con); 178 } 179 297 180 public static function populateObjects(ResultSet $rs) 298 181 { 299 182 $results = array(); 300 183 301 // set the class once to avoid overhead in the loop 302 $cls = QuestionTagPeer::getOMClass(); 184 $cls = QuestionTagPeer::getOMClass(); 303 185 $cls = Propel:
