Index: /tags/release_day_7/frontend/config/factories.yml =================================================================== --- /tags/release_day_7/frontend/config/factories.yml (revision 2) +++ /tags/release_day_7/frontend/config/factories.yml (revision 2) @@ -0,0 +1,27 @@ +test: + storage: + class: sfSessionTestStorage + +all: +; controller: +; class: myFrontWebController +; +; request: +; class: myWebRequest +; +; user: +; class: myUser +; +; storage: +; class: sfSessionStorage +; param: +; session_name: symfony +; +; execution_filter: +; class: sfExecutionFilter +; +; security_filter: +; class: sfBasicSecurityFilter +; +; view_cache: +; class: sfFileCache Index: /tags/release_day_7/frontend/config/app.yml =================================================================== --- /tags/release_day_7/frontend/config/app.yml (revision 14) +++ /tags/release_day_7/frontend/config/app.yml (revision 14) @@ -0,0 +1,5 @@ +# default values +all: + pager: + homepage_max: 2 + answers_max: 1 Index: /tags/release_day_7/frontend/config/settings.yml =================================================================== --- /tags/release_day_7/frontend/config/settings.yml (revision 2) +++ /tags/release_day_7/frontend/config/settings.yml (revision 2) @@ -0,0 +1,86 @@ +prod: + +dev: + .settings: + # E_ALL | E_STRICT = 4095 + error_reporting: 4095 + web_debug: on + cache: off + stats: off + no_script_name: off + +test: + .settings: + # E_ALL | E_STRICT & ~E_NOTICE = 2047 + error_reporting: 2047 + cache: off + stats: off + web_debug: off + +all: +; .actions: +; default_module: default +; default_action: index +; +; error_404_module: default +; error_404_action: error404 +; +; login_module: default +; login_action: login +; +; module_disabled_module: default +; module_disabled_action: disabled +; +; secure_module: default +; secure_action: secure +; +; unavailable_module: default +; unavailable_action: unavailable +; +; .settings: +; available: on +; +; module_accessor: module +; action_accessor: action +; +; content_type: html +; +; path_info_array: SERVER +; path_info_key: PATH_INFO +; +; url_format: PATH +; +; use_database: off +; +; use_security: on +; +; compressed: on +; +; tidy: on +; +; is_i18n: off +; default_culture: en +; +; timeout: 1800 +; +; suffix: . +; +; module_default: on +; +; standard_helpers: Partial,Cache,Form +; +; max_forwards: 20 +; +; web_debug: off +; +; cache: on +; default_cache_lifetime: 86400 +; +; routing: on +; no_script_name: on +; relative_url_root: +; +; stats: off +; +; # E_ERROR | E_USER_ERROR = 257 +; error_reporting: 257 Index: /tags/release_day_7/frontend/config/cache.yml =================================================================== --- /tags/release_day_7/frontend/config/cache.yml (revision 2) +++ /tags/release_day_7/frontend/config/cache.yml (revision 2) @@ -0,0 +1,4 @@ +default: + activate: off + type: slot + lifetime: 86400 Index: /tags/release_day_7/frontend/config/logging.yml =================================================================== --- /tags/release_day_7/frontend/config/logging.yml (revision 2) +++ /tags/release_day_7/frontend/config/logging.yml (revision 2) @@ -0,0 +1,10 @@ +prod: + level: err + +dev: + +test: + +all: +; active: on +; level: debug Index: /tags/release_day_7/frontend/config/databases.yml =================================================================== --- /tags/release_day_7/frontend/config/databases.yml (revision 2) +++ /tags/release_day_7/frontend/config/databases.yml (revision 2) @@ -0,0 +1,35 @@ +databases: + default: Creole + mysql: MySQL + pgsql: PostgreSQL + +Creole: + class: sfCreoleDatabase + param: + dsn: mysql://root:@localhost/db + phptype: mysql + hostspec: localhost + username: root + password: + database: + method: normal + +MySQL: + class: sfMySQLDatabase + param: + user: + password: + database: + host: + persistent: + method: normal + +PostgreSQL: + class: sfPostgreSQLDatabase + param: + user: + password: + database: + host: + persistent: + method: normal Index: /tags/release_day_7/frontend/config/routing.yml =================================================================== --- /tags/release_day_7/frontend/config/routing.yml (revision 18) +++ /tags/release_day_7/frontend/config/routing.yml (revision 18) @@ -0,0 +1,38 @@ +# question +question: + url: /question/:stripped_title + param: { module: question, action: show } + +popular_questions: + url: /index/:page + param: { module: question, action: list } + +recent_questions: + url: /recent + param: { module: question, action: recent } + +# answers +answers: + url: /question/:stripped_title/page/:page + param: { module: question, action: show, page: 1 } + +# login +login: + url: /login + param: { module: user, action: login } + +# default rules +homepage: + url: / + param: { module: question, action: list } + +default_symfony: + url: /symfony/:action/* + param: { module: default } + +default_index: + url: /:module + param: { action: index } + +default: + url: /:module/:action/* Index: /tags/release_day_7/frontend/config/security.yml =================================================================== --- /tags/release_day_7/frontend/config/security.yml (revision 2) +++ /tags/release_day_7/frontend/config/security.yml (revision 2) @@ -0,0 +1,2 @@ +default: + is_secure: off Index: /tags/release_day_7/frontend/config/view.yml =================================================================== --- /tags/release_day_7/frontend/config/view.yml (revision 18) +++ /tags/release_day_7/frontend/config/view.yml (revision 18) @@ -0,0 +1,20 @@ +default: + http_metas: + content-type: text/html; charset=utf-8 + + metas: + title: askeet! ask questions, find answers + robots: index, follow + description: askeet!, a symfony project built in 24 hours + keywords: symfony, project, askeet, php5, question, answer + language: en + + stylesheets: [main, layout] + + javascripts: [] + + has_layout: on + layout: layout + + slots: + sidebar: [sidebar, default] Index: /tags/release_day_7/frontend/config/config.php =================================================================== --- /tags/release_day_7/frontend/config/config.php (revision 2) +++ /tags/release_day_7/frontend/config/config.php (revision 2) @@ -0,0 +1,60 @@ + Index: /tags/release_day_7/frontend/config/orm.yml =================================================================== --- /tags/release_day_7/frontend/config/orm.yml (revision 4) +++ /tags/release_day_7/frontend/config/orm.yml (revision 4) @@ -0,0 +1,6 @@ +all: + adapter: mysql + host: localhost + database: askeet + username: root + password: Index: /tags/release_day_7/frontend/config/tidy.conf =================================================================== --- /tags/release_day_7/frontend/config/tidy.conf (revision 2) +++ /tags/release_day_7/frontend/config/tidy.conf (revision 2) @@ -0,0 +1,8 @@ +output-xhtml: yes +indent: no +wrap: 1000 +tidy-mark: no +hide-comments: yes +char-encoding: utf8 +show-body-only: yes +accessibility-check: 1 Index: /tags/release_day_7/frontend/lib/helper/AnswerHelper.php =================================================================== --- /tags/release_day_7/frontend/lib/helper/AnswerHelper.php (revision 14) +++ /tags/release_day_7/frontend/lib/helper/AnswerHelper.php (revision 14) @@ -0,0 +1,8 @@ +getStrippedTitle().'&page='.$page); +} + +?> Index: /tags/release_day_7/frontend/lib/helper/QuestionHelper.php =================================================================== --- /tags/release_day_7/frontend/lib/helper/QuestionHelper.php (revision 14) +++ /tags/release_day_7/frontend/lib/helper/QuestionHelper.php (revision 14) @@ -0,0 +1,8 @@ + Index: /tags/release_day_7/frontend/lib/myConsoleController.class.php =================================================================== --- /tags/release_day_7/frontend/lib/myConsoleController.class.php (revision 2) +++ /tags/release_day_7/frontend/lib/myConsoleController.class.php (revision 2) @@ -0,0 +1,7 @@ + Index: /tags/release_day_7/frontend/lib/myWebRequest.class.php =================================================================== --- /tags/release_day_7/frontend/lib/myWebRequest.class.php (revision 2) +++ /tags/release_day_7/frontend/lib/myWebRequest.class.php (revision 2) @@ -0,0 +1,7 @@ + Index: /tags/release_day_7/frontend/lib/myFrontWebController.class.php =================================================================== --- /tags/release_day_7/frontend/lib/myFrontWebController.class.php (revision 2) +++ /tags/release_day_7/frontend/lib/myFrontWebController.class.php (revision 2) @@ -0,0 +1,7 @@ + Index: /tags/release_day_7/frontend/lib/myView.class.php =================================================================== --- /tags/release_day_7/frontend/lib/myView.class.php (revision 2) +++ /tags/release_day_7/frontend/lib/myView.class.php (revision 2) @@ -0,0 +1,7 @@ + Index: /tags/release_day_7/frontend/lib/myConsoleRequest.class.php =================================================================== --- /tags/release_day_7/frontend/lib/myConsoleRequest.class.php (revision 2) +++ /tags/release_day_7/frontend/lib/myConsoleRequest.class.php (revision 2) @@ -0,0 +1,7 @@ + Index: /tags/release_day_7/frontend/lib/myAction.class.php =================================================================== --- /tags/release_day_7/frontend/lib/myAction.class.php (revision 2) +++ /tags/release_day_7/frontend/lib/myAction.class.php (revision 2) @@ -0,0 +1,7 @@ + Index: /tags/release_day_7/frontend/lib/myLoginValidator.class.php =================================================================== --- /tags/release_day_7/frontend/lib/myLoginValidator.class.php (revision 16) +++ /tags/release_day_7/frontend/lib/myLoginValidator.class.php (revision 16) @@ -0,0 +1,70 @@ +getParameterHolder()->set('login_error', 'Invalid input'); + + $this->getParameterHolder()->add($parameters); + + return true; + } + + /** + * Execute this validator. + * + * @param mixed A file or parameter value/array. + * @param error An error message reference. + * + * @return bool true, if this validator executes successfully, otherwise + * false. + */ + public function execute (&$value, &$error) + { + $password_param = $this->getParameterHolder()->get('password'); + $password = $this->getContext()->getRequest()->getParameter($password_param); + + $login = $value; + + // anonymous is not a real user + if ($login == 'anonymous') + { + $error = $this->getParameterHolder()->get('login_error'); + return false; + } + + $c = new Criteria(); + $c->add(UserPeer::NICKNAME, $login); + $user = UserPeer::doSelectOne($c); + + // nickname exists? + if ($user) + { + // password is OK? + if (sha1($user->getSalt().$password) == $user->getSha1Password()) + { + $this->getContext()->getUser()->signIn($user); + + return true; + } + } + + $error = $this->getParameterHolder()->get('login_error'); + return false; + } +} + +?> Index: /tags/release_day_7/frontend/lib/myUser.class.php =================================================================== --- /tags/release_day_7/frontend/lib/myUser.class.php (revision 16) +++ /tags/release_day_7/frontend/lib/myUser.class.php (revision 16) @@ -0,0 +1,38 @@ +setAttribute('subscriber_id', $user->getId(), 'subscriber'); + $this->setAuthenticated(true); + + $this->addCredential('subscriber'); + $this->setAttribute('nickname', $user->getNickname(), 'subscriber'); + } + + public function signOut() + { + $this->getAttributeHolder()->removeNamespace('subscriber'); + + $this->setAuthenticated(false); + $this->clearCredentials(); + } + + public function getSubscriberId() + { + return $this->getAttribute('subscriber_id', '', 'subscriber'); + } + + public function getSubscriber() + { + return UserPeer::retrieveByPk($this->getSubscriberId()); + } + + public function getNickname() + { + return $this->getAttribute('nickname', '', 'subscriber'); + } +} + +?> Index: /tags/release_day_7/frontend/modules/answer/actions/actions.class.php =================================================================== --- /tags/release_day_7/frontend/modules/answer/actions/actions.class.php (revision 18) +++ /tags/release_day_7/frontend/modules/answer/actions/actions.class.php (revision 18) @@ -0,0 +1,19 @@ +answer_pager = AnswerPeer::getRecentPager($this->getRequestParameter('page', 1)); + } +} + +?> Index: /tags/release_day_7/frontend/modules/answer/templates/recentSuccess.php =================================================================== --- /tags/release_day_7/frontend/modules/answer/templates/recentSuccess.php (revision 18) +++ /tags/release_day_7/frontend/modules/answer/templates/recentSuccess.php (revision 18) @@ -0,0 +1,22 @@ + + +

recent answers

+ + $answer_pager)) ?> + +haveToPaginate()): ?> +
+ + + getPreviousPage()) ?> + + getLinks() as $page): ?> + getPage()) ? $page : link_to($page, 'answer/recent?page='.$page) ?> + getCurrentMaxLink()) ? '-' : '' ?> + + + getNextPage()) ?> + getLastPage()) ?> + +
+ Index: /tags/release_day_7/frontend/modules/answer/templates/_list.php =================================================================== --- /tags/release_day_7/frontend/modules/answer/templates/_list.php (revision 18) +++ /tags/release_day_7/frontend/modules/answer/templates/_list.php (revision 18) @@ -0,0 +1,14 @@ + + +
+getResults() as $answer): ?> +
+ getRelevancyUpPercent() ?>% UP getRelevancyDownPercent() ?> % DOWN + posted by getUser() ?> + on getCreatedAt(), 'p') ?> +
+ getBody() ?> +
+
+ +
Index: /tags/release_day_7/frontend/modules/question/actions/actions.class.php =================================================================== --- /tags/release_day_7/frontend/modules/question/actions/actions.class.php (revision 18) +++ /tags/release_day_7/frontend/modules/question/actions/actions.class.php (revision 18) @@ -0,0 +1,32 @@ +question_pager = QuestionPeer::getHomepagePager($this->getRequestParameter('page', 1)); + } + + public function executeShow() + { + $this->question = QuestionPeer::getQuestionFromTitle($this->getRequestParameter('stripped_title')); + $this->forward404Unless($this->question); + + $this->answer_pager = AnswerPeer::getPager($this->question->getId(), $this->getRequestParameter('page', 1)); + } + + public function executeRecent() + { + $this->question_pager = QuestionPeer::getRecentPager($this->getRequestParameter('page', 1)); + } +} + +?> Index: /tags/release_day_7/frontend/modules/question/config/security.yml =================================================================== --- /tags/release_day_7/frontend/modules/question/config/security.yml (revision 16) +++ /tags/release_day_7/frontend/modules/question/config/security.yml (revision 16) @@ -0,0 +1,6 @@ +edit: + is_secure: on + credentials: subscriber + +all: + is_secure: off Index: /tags/release_day_7/frontend/modules/question/templates/recentSuccess.php =================================================================== --- /tags/release_day_7/frontend/modules/question/templates/recentSuccess.php (revision 18) +++ /tags/release_day_7/frontend/modules/question/templates/recentSuccess.php (revision 18) @@ -0,0 +1,3 @@ +

recent questions

+ + $question_pager)) ?> Index: /tags/release_day_7/frontend/modules/question/templates/showSuccess.php =================================================================== --- /tags/release_day_7/frontend/modules/question/templates/showSuccess.php (revision 18) +++ /tags/release_day_7/frontend/modules/question/templates/showSuccess.php (revision 18) @@ -0,0 +1,30 @@ + + +
+ $question)) ?> +
+ +

getTitle() ?>

+ +
+ getBody() ?> +
+ + $answer_pager)) ?> + +haveToPaginate()): ?> +
+ + + getPreviousPage()) ?> + + getLinks() as $page): ?> + getPage()) ? $page : answer_pager_link($page, $question, $page) ?> + getCurrentMaxLink()) ? '-' : '' ?> + + + getNextPage()) ?> + getLastPage()) ?> + +
+ Index: /tags/release_day_7/frontend/modules/question/templates/_question_list.php =================================================================== --- /tags/release_day_7/frontend/modules/question/templates/_question_list.php (revision 14) +++ /tags/release_day_7/frontend/modules/question/templates/_question_list.php (revision 14) @@ -0,0 +1,28 @@ + + +getResults() as $question): ?> +
+ $question)) ?> +
+ +

getTitle(), 'question/show?stripped_title='.$question->getStrippedTitle()) ?>

+ +
+ getBody(), 200) ?> +
+ + +
+haveToPaginate()): ?> + + getPreviousPage()) ?> + + getLinks() as $page): ?> + getPage(), $page, 'question/list?page='.$page) ?> + getCurrentMaxLink()) ? '-' : '' ?> + + + getNextPage()) ?> + getLastPage()) ?> + +
Index: /tags/release_day_7/frontend/modules/question/templates/_interested_user.php =================================================================== --- /tags/release_day_7/frontend/modules/question/templates/_interested_user.php (revision 12) +++ /tags/release_day_7/frontend/modules/question/templates/_interested_user.php (revision 12) @@ -0,0 +1,3 @@ +
+ getInterests()) ?> +
Index: /tags/release_day_7/frontend/modules/question/templates/listSuccess.php =================================================================== --- /tags/release_day_7/frontend/modules/question/templates/listSuccess.php (revision 14) +++ /tags/release_day_7/frontend/modules/question/templates/listSuccess.php (revision 14) @@ -0,0 +1,3 @@ +

popular questions

+ + $question_pager)) ?> Index: /tags/release_day_7/frontend/modules/sidebar/actions/actions.class.php =================================================================== --- /tags/release_day_7/frontend/modules/sidebar/actions/actions.class.php (revision 18) +++ /tags/release_day_7/frontend/modules/sidebar/actions/actions.class.php (revision 18) @@ -0,0 +1,18 @@ + Index: /tags/release_day_7/frontend/modules/sidebar/config/module.yml =================================================================== --- /tags/release_day_7/frontend/modules/sidebar/config/module.yml (revision 18) +++ /tags/release_day_7/frontend/modules/sidebar/config/module.yml (revision 18) @@ -0,0 +1,2 @@ +all: + is_internal: on Index: /tags/release_day_7/frontend/modules/sidebar/templates/defaultSuccess.php =================================================================== --- /tags/release_day_7/frontend/modules/sidebar/templates/defaultSuccess.php (revision 18) +++ /tags/release_day_7/frontend/modules/sidebar/templates/defaultSuccess.php (revision 18) @@ -0,0 +1,7 @@ + + + Index: /tags/release_day_7/frontend/modules/user/actions/actions.class.php =================================================================== --- /tags/release_day_7/frontend/modules/user/actions/actions.class.php (revision 18) +++ /tags/release_day_7/frontend/modules/user/actions/actions.class.php (revision 18) @@ -0,0 +1,60 @@ +question = QuestionPeer::retrieveByPk($this->getRequestParameter('id')); + $this->forward404Unless($this->question instanceof Question); + + $this->interested_users = $this->question->getAllInterestedUsers(); + } + + public function executeShow() + { + $this->subscriber = UserPeer::retrieveByPk($this->getRequestParameter('id', $this->getUser()->getSubscriberId())); + $this->forward404Unless($this->subscriber); + + $this->interests = $this->subscriber->getInterestsJoinQuestion(); + $this->answers = $this->subscriber->getAnswersJoinQuestion(); + $this->questions = $this->subscriber->getQuestions(); + } + + public function executeLogin() + { + if ($this->getRequest()->getMethod() != sfRequest::POST) + { + // display the form + $this->getRequest()->getParameterHolder()->set('referer', $this->getRequest()->getReferer()); + return sfView::SUCCESS; + } + else + { + // handle the form submission + // redirect to last page + return $this->redirect($this->getRequestParameter('referer', '@homepage')); + } + } + + public function executeLogout() + { + $this->getUser()->signOut(); + + $this->redirect('@homepage'); + } + + public function handleErrorLogin() + { + return sfView::SUCCESS; + } +} + +?> Index: /tags/release_day_7/frontend/modules/user/validate/login.yml =================================================================== --- /tags/release_day_7/frontend/modules/user/validate/login.yml (revision 16) +++ /tags/release_day_7/frontend/modules/user/validate/login.yml (revision 16) @@ -0,0 +1,24 @@ +methods: + post: [nickname, password] + +names: + nickname: + required: Yes + required_msg: your nickname is required + validators: nicknameValidator, userValidator + + password: + required: Yes + required_msg: your password is required + +nicknameValidator: + class: sfStringValidator + param: + min: 5 + min_error: nickname must be 5 or more characters + +userValidator: + class: myLoginValidator + param: + password: password + login_error: this account does not exist or you entered a wrong password Index: /tags/release_day_7/frontend/modules/user/templates/showSuccess.php =================================================================== --- /tags/release_day_7/frontend/modules/user/templates/showSuccess.php (revision 18) +++ /tags/release_day_7/frontend/modules/user/templates/showSuccess.php (revision 18) @@ -0,0 +1,28 @@ + + +

Interests

+ + + +

Contributions

+ + + +

Questions

+ + Index: /tags/release_day_7/frontend/modules/user/templates/loginSuccess.php =================================================================== --- /tags/release_day_7/frontend/modules/user/templates/loginSuccess.php (revision 16) +++ /tags/release_day_7/frontend/modules/user/templates/loginSuccess.php (revision 16) @@ -0,0 +1,23 @@ + + + +
+ +
+ + + get('nickname')) ?> +
+ +
+ + + +
+ +
+ + getAttribute('referer')) ?> + + + Index: /tags/release_day_7/frontend/modules/user/templates/listInterestedBySuccess.php =================================================================== --- /tags/release_day_7/frontend/modules/user/templates/listInterestedBySuccess.php (revision 18) +++ /tags/release_day_7/frontend/modules/user/templates/listInterestedBySuccess.php (revision 18) @@ -0,0 +1,11 @@ + + +

getTitle() ?>

+

asked by getUser() ?> getCreatedAt('U')) ?> ago

+ + askeet users are interested by this question + Index: /tags/release_day_7/frontend/templates/error.php =================================================================== --- /tags/release_day_7/frontend/templates/error.php (revision 2) +++ /tags/release_day_7/frontend/templates/error.php (revision 2) @@ -0,0 +1,101 @@ + + + + +symfony exception + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0): ?> + + + + + + + + + + + + + + + + + + +
message: + + learn more about this issue + +
code:
class:
file:
line:
stack trace
info
symfonyv.
PHPv.
for help resolving this issue, please visit www.symfony-project.com.
+ + + Index: /tags/release_day_7/frontend/templates/layout.php =================================================================== --- /tags/release_day_7/frontend/templates/layout.php (revision 18) +++ /tags/release_day_7/frontend/templates/layout.php (revision 18) @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+
+
+ + + Index: /tags/release_day_7/frontend/templates/error.txt =================================================================== --- /tags/release_day_7/frontend/templates/error.txt (revision 2) +++ /tags/release_day_7/frontend/templates/error.txt (revision 2) @@ -0,0 +1,16 @@ +[exception] +[message] +[code] +[class] +[file] +[line] +[symfony] v. (symfony-project.com) +[PHP] v. + 0): ?> +[stack trace] + + + + + + Index: /tags/release_day_7/test/frontend/sidebarActionsTest.php =================================================================== --- /tags/release_day_7/test/frontend/sidebarActionsTest.php (revision 18) +++ /tags/release_day_7/test/frontend/sidebarActionsTest.php (revision 18) @@ -0,0 +1,28 @@ +browser = new sfTestBrowser(); + $this->browser->initialize('hostname'); + } + + public function tearDown () + { + $this->browser->shutdown(); + } + + public function test_simple() + { + $url = '/sidebar/index'; + $html = $this->browser->get($url); + $this->assertWantedPattern('/sidebar/', $html); + } +} + +?> Index: /tags/release_day_7/test/frontend/userActionsTest.php =================================================================== --- /tags/release_day_7/test/frontend/userActionsTest.php (revision 14) +++ /tags/release_day_7/test/frontend/userActionsTest.php (revision 14) @@ -0,0 +1,28 @@ +browser = new sfTestBrowser(); + $this->browser->initialize('hostname'); + } + + public function tearDown () + { + $this->browser->shutdown(); + } + + public function test_simple() + { + $url = '/user/index'; + $html = $this->browser->get($url); + $this->assertWantedPattern('/user/', $html); + } +} + +?> Index: /tags/release_day_7/test/frontend/answerActionsTest.php =================================================================== --- /tags/release_day_7/test/frontend/answerActionsTest.php (revision 18) +++ /tags/release_day_7/test/frontend/answerActionsTest.php (revision 18) @@ -0,0 +1,28 @@ +browser = new sfTestBrowser(); + $this->browser->initialize('hostname'); + } + + public function tearDown () + { + $this->browser->shutdown(); + } + + public function test_simple() + { + $url = '/answer/index'; + $html = $this->browser->get($url); + $this->assertWantedPattern('/answer/', $html); + } +} + +?> Index: /tags/release_day_7/batch/load_data.php =================================================================== --- /tags/release_day_7/batch/load_data.php (revision 12) +++ /tags/release_day_7/batch/load_data.php (revision 12) @@ -0,0 +1,13 @@ +loadData(SF_DATA_DIR.DIRECTORY_SEPARATOR.'fixtures'); + +?> Index: /tags/release_day_7/config/propel.ini =================================================================== --- /tags/release_day_7/config/propel.ini (revision 4) +++ /tags/release_day_7/config/propel.ini (revision 4) @@ -0,0 +1,38 @@ +propel.targetPackage = model +propel.project = askeet +propel.database = mysql +propel.database.createUrl = mysql://localhost/ +propel.database.url = mysql://localhost/askeet + +propel.mysql.tableType = InnoDB + +propel.addGenericAccessors = true +propel.addGenericMutators = true +propel.addTimeStamp = false + +; directories +propel.home = . +propel.output.dir = /home/production/askeetsvn +propel.schema.dir = ${propel.output.dir}/config +propel.conf.dir = ${propel.output.dir}/config +propel.phpconf.dir = ${propel.output.dir}/config +propel.sql.dir = ${propel.output.dir}/data/sql +propel.runtime.conf.file = runtime-conf.xml +propel.php.dir = ${propel.output.dir}/lib +propel.default.schema.basename = schema +propel.datadump.mapper.from = *schema.xml +propel.datadump.mapper.to = *data.xml + +; builder settings +propel.builder.peer.class = symfony.symfony.addon.propel.builder.SfPeerBuilder +propel.builder.object.class = symfony.symfony.addon.propel.builder.SfObjectBuilder + +propel.builder.objectstub.class = propel.engine.builder.om.php5.PHP5ExtensionObjectBuilder +propel.builder.peerstub.class = propel.engine.builder.om.php5.PHP5ExtensionPeerBuilder +propel.builder.objectmultiextend.class = propel.engine.builder.om.php5.PHP5MultiExtendObjectBuilder +propel.builder.mapbuilder.class = propel.engine.builder.om.php5.PHP5MapBuilderBuilder +propel.builder.interface.class = propel.engine.builder.om.php5.PHP5InterfaceBuilder +propel.builder.node.class = propel.engine.builder.om.php5.PHP5NodeBuilder +propel.builder.nodepeer.class = propel.engine.builder.om.php5.PHP5NodePeerBuilder +propel.builder.nodestub.class = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder +propel.builder.nodepeerstub.class = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder Index: /tags/release_day_7/config/schema.xml =================================================================== --- /tags/release_day_7/config/schema.xml (revision 16) +++ /tags/release_day_7/config/schema.xml (revision 16) @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + +
+ +
Index: /tags/release_day_7/config/doc_header.html =================================================================== --- /tags/release_day_7/config/doc_header.html (revision 2) +++ /tags/release_day_7/config/doc_header.html (revision 2) @@ -0,0 +1,6 @@ + + + project documentation + + + Index: /tags/release_day_7/config/apache.conf =================================================================== --- /tags/release_day_7/config/apache.conf (revision 2) +++ /tags/release_day_7/config/apache.conf (revision 2) @@ -0,0 +1,10 @@ + + ServerName askeet + DocumentRoot "/home/sfprojects/askeet/web" + DirectoryIndex index.php + Alias /sf /usr/local/lib/php/data/symfony/web/sf + + + AllowOverride All + + Index: /tags/release_day_7/config/rsync_exclude.txt =================================================================== --- /tags/release_day_7/config/rsync_exclude.txt (revision 2) +++ /tags/release_day_7/config/rsync_exclude.txt (revision 2) @@ -0,0 +1,5 @@ +stats +.svn +web/uploads +cache +log Index: /tags/release_day_7/config/doc_footer.html =================================================================== --- /tags/release_day_7/config/doc_footer.html (revision 2) +++ /tags/release_day_7/config/doc_footer.html (revision 2) @@ -0,0 +1,2 @@ + + Index: /tags/release_day_7/config/properties.ini =================================================================== --- /tags/release_day_7/config/properties.ini (revision 2) +++ /tags/release_day_7/config/properties.ini (revision 2) @@ -0,0 +1,2 @@ +[symfony] + name=askeet Index: /tags/release_day_7/config/config.php =================================================================== --- /tags/release_day_7/config/config.php (revision 2) +++ /tags/release_day_7/config/config.php (revision 2) @@ -0,0 +1,3 @@ + Index: /tags/release_day_7/config/doxygen.cfg =================================================================== --- /tags/release_day_7/config/doxygen.cfg (revision 2) +++ /tags/release_day_7/config/doxygen.cfg (revision 2) @@ -0,0 +1,1161 @@ +# Doxyfile 1.3.9.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = ##PROJECT_NAME## + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = $Id$ + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of source +# files, where putting all generated files in the same directory would otherwise +# cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, +# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, +# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, +# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, +# Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# This tag can be used to specify the encoding used in the generated output. +# The encoding is not always determined by the language that is chosen, +# but also whether or not the output is meant for Windows or non-Windows users. +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES +# forces the Windows encoding (this is the default for the Windows binary), +# whereas setting the tag to NO uses a Unix-style encoding (the default for +# all platforms other than Windows). + +USE_WINDOWS_ENCODING = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is used +# as the annotated text. Otherwise, the brief description is used as-is. If left +# blank, the following values are used ("$name" is automatically replaced with the +# name of the entity): "The $name class" "The $name widget" "The $name file" +# "is" "provides" "specifies" "contains" "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited +# members of a class in the documentation of that class as if those members were +# ordinary class members. Constructors, destructors and assignment operators of +# the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 2 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources +# only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = NO + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. + +SHOW_DIRECTORIES = YES + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = lib fo/lib fo/modules + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp +# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm + +FILE_PATTERNS = *.php + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories +# that are symbolic links (a Unix filesystem feature) are excluded from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = */.svn/* */templates/* + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = header.html + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = YES + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = YES + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse the +# parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or +# super classes. Setting the tag to NO turns the diagrams off. Note that this +# option is superseded by the HAVE_DOT option below. This is only a fallback. It is +# recommended to install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found on the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes that +# lay further from the root node will be omitted. Note that setting this option to +# 1 or 2 may greatly reduce the computation time needed for large code bases. Also +# note that a graph may be further truncated if the graph's image dimensions are +# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). +# If 0 is used for the depth value (the default), the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO Index: /tags/release_day_7/lib/model/InterestPeer.php =================================================================== --- /tags/release_day_7/lib/model/InterestPeer.php (revision 4) +++ /tags/release_day_7/lib/model/InterestPeer.php (revision 4) @@ -0,0 +1,23 @@ +add(self::QUESTION_ID, $question_id); + $c->addDescendingOrderByColumn(self::RELEVANCY_UP); + $c->addDescendingOrderByColumn(self::CREATED_AT); + $pager->setCriteria($c); + $pager->setPage($page); + $pager->init(); + + return $pager; + } + + public static function getRecentPager($page) + { + $pager = new sfPager('Answer', APP_PAGER_HOMEPAGE_MAX); + $c = new Criteria(); + $c->addDescendingOrderByColumn(self::CREATED_AT); + $pager->setCriteria($c); + $pager->setPage($page); + $pager->setPeerMethod('doSelectJoinUser'); + $pager->init(); + + return $pager; + } +} + +?> Index: /tags/release_day_7/lib/model/Interest.php =================================================================== --- /tags/release_day_7/lib/model/Interest.php (revision 12) +++ /tags/release_day_7/lib/model/Interest.php (revision 12) @@ -0,0 +1,46 @@ +begin(); + + $ret = parent::save(); + + // update interested_users in question table + $question = $this->getQuestion(); + $interested_users = $question->getInterestedUsers(); + $question->setInterestedUsers($interested_users + 1); + $question->save(); + + $con->commit(); + + return $ret; + } + catch (Exception $e) + { + $con->rollback(); + throw $e; + } + } +} + +?> Index: /tags/release_day_7/lib/model/User.php =================================================================== --- /tags/release_day_7/lib/model/User.php (revision 16) +++ /tags/release_day_7/lib/model/User.php (revision 16) @@ -0,0 +1,32 @@ +getFirstName().' '.$this->getLastName(); + } + + public function setPassword($password) + { + $salt = md5(rand(100000, 999999).$this->getNickname().$this->getEmail()); + $this->setSalt($salt); + $this->setSha1Password(sha1($salt.$password)); + } +} + +?> Index: /tags/release_day_7/lib/model/Answer.php =================================================================== --- /tags/release_day_7/lib/model/Answer.php (revision 12) +++ /tags/release_day_7/lib/model/Answer.php (revision 12) @@ -0,0 +1,34 @@ +getRelevancyUp() + $this->getRelevancyDown(); + + return $total ? sprintf('%02.0f', $this->getRelevancyUp() * 100 / $total) : 0; + } + + public function getRelevancyDownPercent() + { + $total = $this->getRelevancyUp() + $this->getRelevancyDown(); + + return $total ? sprintf('%02.0f', $this->getRelevancyDown() * 100 / $total) : 0; + } +} + +?> Index: /tags/release_day_7/lib/model/QuestionPeer.php =================================================================== --- /tags/release_day_7/lib/model/QuestionPeer.php (revision 18) +++ /tags/release_day_7/lib/model/QuestionPeer.php (revision 18) @@ -0,0 +1,60 @@ +add(self::STRIPPED_TITLE, $title); + + $questions = self::doSelectJoinUser($c); + + return $questions ? $questions[0] : null; + } + + public static function getHomepagePager($page) + { + $pager = new sfPager('Question', APP_PAGER_HOMEPAGE_MAX); + $c = new Criteria(); + $c->addDescendingOrderByColumn(self::INTERESTED_USERS); + $pager->setCriteria($c); + $pager->setPage($page); + $pager->setPeerMethod('doSelectJoinUser'); + $pager->init(); + + return $pager; + } + + public static function getRecentPager($page) + { + $pager = new sfPager('Question', APP_PAGER_HOMEPAGE_MAX); + $c = new Criteria(); + $c->addDescendingOrderByColumn(self::CREATED_AT); + $pager->setCriteria($c); + $pager->setPage($page); + $pager->setPeerMethod('doSelectJoinUser'); + $pager->init(); + + return $pager; + } +} + +?> Index: /tags/release_day_7/lib/model/RelevancyPeer.php =================================================================== --- /tags/release_day_7/lib/model/RelevancyPeer.php (revision 4) +++ /tags/release_day_7/lib/model/RelevancyPeer.php (revision 4) @@ -0,0 +1,23 @@ +id; + } + + /** + * Get the [nickname] column value. + * + * @return string + */ + public function getNickname() + { + + return $this->nickname; + } + + /** + * Get the [first_name] column value. + * + * @return string + */ + public function getFirstName() + { + + return $this->first_name; + } + + /** + * Get the [last_name] column value. + * + * @return string + */ + public function getLastName() + { + + return $this->last_name; + } + + /** + * Get the [email] column value. + * + * @return string + */ + public function getEmail() + { + + return $this->email; + } + + /** + * Get the [sha1_password] column value. + * + * @return string + */ + public function getSha1Password() + { + + return $this->sha1_password; + } + + /** + * Get the [salt] column value. + * + * @return string + */ + public function getSalt() + { + + return $this->salt; + } + + /** + * Get the [optionally formatted] [created_at] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + + if ($this->created_at === null || $this->created_at === '') { + return null; + } elseif (!is_int($this->created_at)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->created_at); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); + } + } else { + $ts = $this->created_at; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return void + */ + public function setId($v) + { + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = UserPeer::ID; + } + + } // setId() + + /** + * Set the value of [nickname] column. + * + * @param string $v new value + * @return void + */ + public function setNickname($v) + { + + if ($this->nickname !== $v) { + $this->nickname = $v; + $this->modifiedColumns[] = UserPeer::NICKNAME; + } + + } // setNickname() + + /** + * Set the value of [first_name] column. + * + * @param string $v new value + * @return void + */ + public function setFirstName($v) + { + + if ($this->first_name !== $v) { + $this->first_name = $v; + $this->modifiedColumns[] = UserPeer::FIRST_NAME; + } + + } // setFirstName() + + /** + * Set the value of [last_name] column. + * + * @param string $v new value + * @return void + */ + public function setLastName($v) + { + + if ($this->last_name !== $v) { + $this->last_name = $v; + $this->modifiedColumns[] = UserPeer::LAST_NAME; + } + + } // setLastName() + + /** + * Set the value of [email] column. + * + * @param string $v new value + * @return void + */ + public function setEmail($v) + { + + if ($this->email !== $v) { + $this->email = $v; + $this->modifiedColumns[] = UserPeer::EMAIL; + } + + } // setEmail() + + /** + * Set the value of [sha1_password] column. + * + * @param string $v new value + * @return void + */ + public function setSha1Password($v) + { + + if ($this->sha1_password !== $v) { + $this->sha1_password = $v; + $this->modifiedColumns[] = UserPeer::SHA1_PASSWORD; + } + + } // setSha1Password() + + /** + * Set the value of [salt] column. + * + * @param string $v new value + * @return void + */ + public function setSalt($v) + { + + if ($this->salt !== $v) { + $this->salt = $v; + $this->modifiedColumns[] = UserPeer::SALT; + } + + } // setSalt() + + /** + * Set the value of [created_at] column. + * + * @param int $v new value + * @return void + */ + public function setCreatedAt($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->created_at !== $ts) { + $this->created_at = $ts; + $this->modifiedColumns[] = UserPeer::CREATED_AT; + } + + } // setCreatedAt() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->nickname = $rs->getString($startcol + 1); + + $this->first_name = $rs->getString($startcol + 2); + + $this->last_name = $rs->getString($startcol + 3); + + $this->email = $rs->getString($startcol + 4); + + $this->sha1_password = $rs->getString($startcol + 5); + + $this->salt = $rs->getString($startcol + 6); + + $this->created_at = $rs->getTimestamp($startcol + 7, null); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 8; // 8 = UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating User object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(UserPeer::DATABASE_NAME); + } + + try { + $con->begin(); + UserPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isNew()) + { + $this->setCreatedAt(time()); + } + + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(UserPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = UserPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setId($pk); //[IMV] update autoincrement primary key + + $this->setNew(false); + } else { + $affectedRows += UserPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + if ($this->collQuestions !== null) { + foreach($this->collQuestions as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collAnswers !== null) { + foreach($this->collAnswers as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collInterests !== null) { + foreach($this->collInterests as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collRelevancys !== null) { + foreach($this->collRelevancys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * + * @return mixed true if all columns pass validation + * or an array of ValidationFailed objects for columns that fail. + * @see doValidate() + */ + public function validate($columns = null) + { + if ($columns) { + return UserPeer::doValidate($this, $columns); + } + return $this->doValidate(); + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate() + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = UserPeer::doValidate($this)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collQuestions !== null) { + foreach($this->collQuestions as $referrerFK) { + if (($retval = $referrerFK->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + } + + if ($this->collAnswers !== null) { + foreach($this->collAnswers as $referrerFK) { + if (($retval = $referrerFK->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + } + + if ($this->collInterests !== null) { + foreach($this->collInterests as $referrerFK) { + if (($retval = $referrerFK->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + } + + if ($this->collRelevancys !== null) { + foreach($this->collRelevancys as $referrerFK) { + if (($retval = $referrerFK->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + } + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $names = UserPeer::getFieldNames($type); + $pos = UserPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getNickname(); + break; + case 2: + return $this->getFirstName(); + break; + case 3: + return $this->getLastName(); + break; + case 4: + return $this->getEmail(); + break; + case 5: + return $this->getSha1Password(); + break; + case 6: + return $this->getSalt(); + break; + case 7: + return $this->getCreatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = UserPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getNickname(), + $keys[2] => $this->getFirstName(), + $keys[3] => $this->getLastName(), + $keys[4] => $this->getEmail(), + $keys[5] => $this->getSha1Password(), + $keys[6] => $this->getSalt(), + $keys[7] => $this->getCreatedAt(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $names = UserPeer::getFieldNames($type); + $pos = array_search($name, $names); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setNickname($value); + break; + case 2: + $this->setFirstName($value); + break; + case 3: + $this->setLastName($value); + break; + case 4: + $this->setEmail($value); + break; + case 5: + $this->setSha1Password($value); + break; + case 6: + $this->setSalt($value); + break; + case 7: + $this->setCreatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = UserPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setNickname($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFirstName($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setLastName($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setEmail($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setSha1Password($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setSalt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(UserPeer::DATABASE_NAME); + + if ($this->isColumnModified(UserPeer::ID)) $criteria->add(UserPeer::ID, $this->id); + if ($this->isColumnModified(UserPeer::NICKNAME)) $criteria->add(UserPeer::NICKNAME, $this->nickname); + if ($this->isColumnModified(UserPeer::FIRST_NAME)) $criteria->add(UserPeer::FIRST_NAME, $this->first_name); + if ($this->isColumnModified(UserPeer::LAST_NAME)) $criteria->add(UserPeer::LAST_NAME, $this->last_name); + if ($this->isColumnModified(UserPeer::EMAIL)) $criteria->add(UserPeer::EMAIL, $this->email); + if ($this->isColumnModified(UserPeer::SHA1_PASSWORD)) $criteria->add(UserPeer::SHA1_PASSWORD, $this->sha1_password); + if ($this->isColumnModified(UserPeer::SALT)) $criteria->add(UserPeer::SALT, $this->salt); + if ($this->isColumnModified(UserPeer::CREATED_AT)) $criteria->add(UserPeer::CREATED_AT, $this->created_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(UserPeer::DATABASE_NAME); + + $criteria->add(UserPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of User (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setNickname($this->nickname); + + $copyObj->setFirstName($this->first_name); + + $copyObj->setLastName($this->last_name); + + $copyObj->setEmail($this->email); + + $copyObj->setSha1Password($this->sha1_password); + + $copyObj->setSalt($this->salt); + + $copyObj->setCreatedAt($this->created_at); + + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach($this->getQuestions() as $relObj) { + $copyObj->addQuestion($relObj->copy($deepCopy)); + } + + foreach($this->getAnswers() as $relObj) { + $copyObj->addAnswer($relObj->copy($deepCopy)); + } + + foreach($this->getInterests() as $relObj) { + $copyObj->addInterest($relObj->copy($deepCopy)); + } + + foreach($this->getRelevancys() as $relObj) { + $copyObj->addRelevancy($relObj->copy($deepCopy)); + } + + } // if ($deepCopy) + + + $copyObj->setNew(true); + + $copyObj->setId(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return User Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return UserPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new UserPeer(); + } + return self::$peer; + } + + /** + * Temporary storage of collQuestions to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + * @return void + */ + public function initQuestions() + { + if ($this->collQuestions === null) { + $this->collQuestions = array(); + } + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this User has previously + * been saved, it will retrieve related Questions from storage. + * If this User is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @param Connection $con + * @param Criteria $criteria + * @throws PropelException + */ + public function getQuestions($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseQuestionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collQuestions === null) { + if ($this->isNew()) { + $this->collQuestions = array(); + } else { + + $criteria->add(QuestionPeer::USER_ID, $this->getId()); + + QuestionPeer::addSelectColumns($criteria); + $this->collQuestions = QuestionPeer::doSelect($criteria, $con); + } + } else { + // criteria has no effect for a new object + if (!$this->isNew()) { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + + $criteria->add(QuestionPeer::USER_ID, $this->getId()); + + QuestionPeer::addSelectColumns($criteria); + if (!isset($this->lastQuestionCriteria) || !$this->lastQuestionCriteria->equals($criteria)) { + $this->collQuestions = QuestionPeer::doSelect($criteria, $con); + } + } + } + $this->lastQuestionCriteria = $criteria; + return $this->collQuestions; + } + + /** + * Returns the number of related Questions. + * + * @param Criteria $criteria + * @param Connection $con + * @throws PropelException + */ + public function countQuestions($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseQuestionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(QuestionPeer::USER_ID, $this->getId()); + + return QuestionPeer::doCount($criteria, $con); + } + + /** + * Method called to associate a Question object to this object + * through the Question foreign key attribute + * + * @param Question $l Question + * @return void + * @throws PropelException + */ + public function addQuestion(Question $l) + { + $this->collQuestions[] = $l; + $l->setUser($this); + } + + /** + * Temporary storage of collAnswers to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + * @return void + */ + public function initAnswers() + { + if ($this->collAnswers === null) { + $this->collAnswers = array(); + } + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this User has previously + * been saved, it will retrieve related Answers from storage. + * If this User is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @param Connection $con + * @param Criteria $criteria + * @throws PropelException + */ + public function getAnswers($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseAnswerPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAnswers === null) { + if ($this->isNew()) { + $this->collAnswers = array(); + } else { + + $criteria->add(AnswerPeer::USER_ID, $this->getId()); + + AnswerPeer::addSelectColumns($criteria); + $this->collAnswers = AnswerPeer::doSelect($criteria, $con); + } + } else { + // criteria has no effect for a new object + if (!$this->isNew()) { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + + $criteria->add(AnswerPeer::USER_ID, $this->getId()); + + AnswerPeer::addSelectColumns($criteria); + if (!isset($this->lastAnswerCriteria) || !$this->lastAnswerCriteria->equals($criteria)) { + $this->collAnswers = AnswerPeer::doSelect($criteria, $con); + } + } + } + $this->lastAnswerCriteria = $criteria; + return $this->collAnswers; + } + + /** + * Returns the number of related Answers. + * + * @param Criteria $criteria + * @param Connection $con + * @throws PropelException + */ + public function countAnswers($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseAnswerPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(AnswerPeer::USER_ID, $this->getId()); + + return AnswerPeer::doCount($criteria, $con); + } + + /** + * Method called to associate a Answer object to this object + * through the Answer foreign key attribute + * + * @param Answer $l Answer + * @return void + * @throws PropelException + */ + public function addAnswer(Answer $l) + { + $this->collAnswers[] = $l; + $l->setUser($this); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this User is new, it will return + * an empty collection; or if this User has previously + * been saved, it will retrieve related Answers from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in User. + */ + public function getAnswersJoinQuestion($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseAnswerPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAnswers === null) { + if ($this->isNew()) { + $this->collAnswers = array(); + } else { + + $criteria->add(AnswerPeer::USER_ID, $this->getId()); + + $this->collAnswers = AnswerPeer::doSelectJoinQuestion($criteria, $con); + } + } else { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + $criteria->add(AnswerPeer::USER_ID, $this->getId()); + + if (!isset($this->lastAnswerCriteria) || !$this->lastAnswerCriteria->equals($criteria)) { + $this->collAnswers = AnswerPeer::doSelectJoinQuestion($criteria, $con); + } + } + $this->lastAnswerCriteria = $criteria; + + return $this->collAnswers; + } + + /** + * Temporary storage of collInterests to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + * @return void + */ + public function initInterests() + { + if ($this->collInterests === null) { + $this->collInterests = array(); + } + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this User has previously + * been saved, it will retrieve related Interests from storage. + * If this User is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @param Connection $con + * @param Criteria $criteria + * @throws PropelException + */ + public function getInterests($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseInterestPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collInterests === null) { + if ($this->isNew()) { + $this->collInterests = array(); + } else { + + $criteria->add(InterestPeer::USER_ID, $this->getId()); + + InterestPeer::addSelectColumns($criteria); + $this->collInterests = InterestPeer::doSelect($criteria, $con); + } + } else { + // criteria has no effect for a new object + if (!$this->isNew()) { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + + $criteria->add(InterestPeer::USER_ID, $this->getId()); + + InterestPeer::addSelectColumns($criteria); + if (!isset($this->lastInterestCriteria) || !$this->lastInterestCriteria->equals($criteria)) { + $this->collInterests = InterestPeer::doSelect($criteria, $con); + } + } + } + $this->lastInterestCriteria = $criteria; + return $this->collInterests; + } + + /** + * Returns the number of related Interests. + * + * @param Criteria $criteria + * @param Connection $con + * @throws PropelException + */ + public function countInterests($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseInterestPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(InterestPeer::USER_ID, $this->getId()); + + return InterestPeer::doCount($criteria, $con); + } + + /** + * Method called to associate a Interest object to this object + * through the Interest foreign key attribute + * + * @param Interest $l Interest + * @return void + * @throws PropelException + */ + public function addInterest(Interest $l) + { + $this->collInterests[] = $l; + $l->setUser($this); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this User is new, it will return + * an empty collection; or if this User has previously + * been saved, it will retrieve related Interests from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in User. + */ + public function getInterestsJoinQuestion($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseInterestPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collInterests === null) { + if ($this->isNew()) { + $this->collInterests = array(); + } else { + + $criteria->add(InterestPeer::USER_ID, $this->getId()); + + $this->collInterests = InterestPeer::doSelectJoinQuestion($criteria, $con); + } + } else { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + $criteria->add(InterestPeer::USER_ID, $this->getId()); + + if (!isset($this->lastInterestCriteria) || !$this->lastInterestCriteria->equals($criteria)) { + $this->collInterests = InterestPeer::doSelectJoinQuestion($criteria, $con); + } + } + $this->lastInterestCriteria = $criteria; + + return $this->collInterests; + } + + /** + * Temporary storage of collRelevancys to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + * @return void + */ + public function initRelevancys() + { + if ($this->collRelevancys === null) { + $this->collRelevancys = array(); + } + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this User has previously + * been saved, it will retrieve related Relevancys from storage. + * If this User is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @param Connection $con + * @param Criteria $criteria + * @throws PropelException + */ + public function getRelevancys($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseRelevancyPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collRelevancys === null) { + if ($this->isNew()) { + $this->collRelevancys = array(); + } else { + + $criteria->add(RelevancyPeer::USER_ID, $this->getId()); + + RelevancyPeer::addSelectColumns($criteria); + $this->collRelevancys = RelevancyPeer::doSelect($criteria, $con); + } + } else { + // criteria has no effect for a new object + if (!$this->isNew()) { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + + $criteria->add(RelevancyPeer::USER_ID, $this->getId()); + + RelevancyPeer::addSelectColumns($criteria); + if (!isset($this->lastRelevancyCriteria) || !$this->lastRelevancyCriteria->equals($criteria)) { + $this->collRelevancys = RelevancyPeer::doSelect($criteria, $con); + } + } + } + $this->lastRelevancyCriteria = $criteria; + return $this->collRelevancys; + } + + /** + * Returns the number of related Relevancys. + * + * @param Criteria $criteria + * @param Connection $con + * @throws PropelException + */ + public function countRelevancys($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseRelevancyPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(RelevancyPeer::USER_ID, $this->getId()); + + return RelevancyPeer::doCount($criteria, $con); + } + + /** + * Method called to associate a Relevancy object to this object + * through the Relevancy foreign key attribute + * + * @param Relevancy $l Relevancy + * @return void + * @throws PropelException + */ + public function addRelevancy(Relevancy $l) + { + $this->collRelevancys[] = $l; + $l->setUser($this); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this User is new, it will return + * an empty collection; or if this User has previously + * been saved, it will retrieve related Relevancys from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in User. + */ + public function getRelevancysJoinAnswer($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseRelevancyPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collRelevancys === null) { + if ($this->isNew()) { + $this->collRelevancys = array(); + } else { + + $criteria->add(RelevancyPeer::USER_ID, $this->getId()); + + $this->collRelevancys = RelevancyPeer::doSelectJoinAnswer($criteria, $con); + } + } else { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + $criteria->add(RelevancyPeer::USER_ID, $this->getId()); + + if (!isset($this->lastRelevancyCriteria) || !$this->lastRelevancyCriteria->equals($criteria)) { + $this->collRelevancys = RelevancyPeer::doSelectJoinAnswer($criteria, $con); + } + } + $this->lastRelevancyCriteria = $criteria; + + return $this->collRelevancys; + } + +} // BaseUser Index: /tags/release_day_7/lib/model/om/BaseAnswer.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseAnswer.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseAnswer.php (revision 16) @@ -0,0 +1,1148 @@ +id; + } + + /** + * Get the [question_id] column value. + * + * @return int + */ + public function getQuestionId() + { + + return $this->question_id; + } + + /** + * Get the [user_id] column value. + * + * @return int + */ + public function getUserId() + { + + return $this->user_id; + } + + /** + * Get the [body] column value. + * + * @return string + */ + public function getBody() + { + + return $this->body; + } + + /** + * Get the [relevancy_up] column value. + * + * @return int + */ + public function getRelevancyUp() + { + + return $this->relevancy_up; + } + + /** + * Get the [relevancy_down] column value. + * + * @return int + */ + public function getRelevancyDown() + { + + return $this->relevancy_down; + } + + /** + * Get the [optionally formatted] [created_at] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + + if ($this->created_at === null || $this->created_at === '') { + return null; + } elseif (!is_int($this->created_at)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->created_at); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); + } + } else { + $ts = $this->created_at; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return void + */ + public function setId($v) + { + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AnswerPeer::ID; + } + + } // setId() + + /** + * Set the value of [question_id] column. + * + * @param int $v new value + * @return void + */ + public function setQuestionId($v) + { + + if ($this->question_id !== $v) { + $this->question_id = $v; + $this->modifiedColumns[] = AnswerPeer::QUESTION_ID; + } + + if ($this->aQuestion !== null && $this->aQuestion->getId() !== $v) { + $this->aQuestion = null; + } + + } // setQuestionId() + + /** + * Set the value of [user_id] column. + * + * @param int $v new value + * @return void + */ + public function setUserId($v) + { + + if ($this->user_id !== $v) { + $this->user_id = $v; + $this->modifiedColumns[] = AnswerPeer::USER_ID; + } + + if ($this->aUser !== null && $this->aUser->getId() !== $v) { + $this->aUser = null; + } + + } // setUserId() + + /** + * Set the value of [body] column. + * + * @param string $v new value + * @return void + */ + public function setBody($v) + { + + if ($this->body !== $v) { + $this->body = $v; + $this->modifiedColumns[] = AnswerPeer::BODY; + } + + } // setBody() + + /** + * Set the value of [relevancy_up] column. + * + * @param int $v new value + * @return void + */ + public function setRelevancyUp($v) + { + + if ($this->relevancy_up !== $v || $v === 0) { + $this->relevancy_up = $v; + $this->modifiedColumns[] = AnswerPeer::RELEVANCY_UP; + } + + } // setRelevancyUp() + + /** + * Set the value of [relevancy_down] column. + * + * @param int $v new value + * @return void + */ + public function setRelevancyDown($v) + { + + if ($this->relevancy_down !== $v || $v === 0) { + $this->relevancy_down = $v; + $this->modifiedColumns[] = AnswerPeer::RELEVANCY_DOWN; + } + + } // setRelevancyDown() + + /** + * Set the value of [created_at] column. + * + * @param int $v new value + * @return void + */ + public function setCreatedAt($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->created_at !== $ts) { + $this->created_at = $ts; + $this->modifiedColumns[] = AnswerPeer::CREATED_AT; + } + + } // setCreatedAt() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->question_id = $rs->getInt($startcol + 1); + + $this->user_id = $rs->getInt($startcol + 2); + + $this->body = $rs->getString($startcol + 3); + + $this->relevancy_up = $rs->getInt($startcol + 4); + + $this->relevancy_down = $rs->getInt($startcol + 5); + + $this->created_at = $rs->getTimestamp($startcol + 6, null); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 7; // 7 = AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating Answer object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(AnswerPeer::DATABASE_NAME); + } + + try { + $con->begin(); + AnswerPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isNew()) + { + $this->setCreatedAt(time()); + } + + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(AnswerPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // We call the save method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aQuestion !== null) { + if ($this->aQuestion->isModified()) { + $affectedRows += $this->aQuestion->save($con); + } + $this->setQuestion($this->aQuestion); + } + + if ($this->aUser !== null) { + if ($this->aUser->isModified()) { + $affectedRows += $this->aUser->save($con); + } + $this->setUser($this->aUser); + } + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = AnswerPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setId($pk); //[IMV] update autoincrement primary key + + $this->setNew(false); + } else { + $affectedRows += AnswerPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + if ($this->collRelevancys !== null) { + foreach($this->collRelevancys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * + * @return mixed true if all columns pass validation + * or an array of ValidationFailed objects for columns that fail. + * @see doValidate() + */ + public function validate($columns = null) + { + if ($columns) { + return AnswerPeer::doValidate($this, $columns); + } + return $this->doValidate(); + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate() + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + // We call the validate method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aQuestion !== null) { + if (($retval = $this->aQuestion->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + + if ($this->aUser !== null) { + if (($retval = $this->aUser->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + + + if (($retval = AnswerPeer::doValidate($this)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collRelevancys !== null) { + foreach($this->collRelevancys as $referrerFK) { + if (($retval = $referrerFK->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + } + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $names = AnswerPeer::getFieldNames($type); + $pos = AnswerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getQuestionId(); + break; + case 2: + return $this->getUserId(); + break; + case 3: + return $this->getBody(); + break; + case 4: + return $this->getRelevancyUp(); + break; + case 5: + return $this->getRelevancyDown(); + break; + case 6: + return $this->getCreatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = AnswerPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getQuestionId(), + $keys[2] => $this->getUserId(), + $keys[3] => $this->getBody(), + $keys[4] => $this->getRelevancyUp(), + $keys[5] => $this->getRelevancyDown(), + $keys[6] => $this->getCreatedAt(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $names = AnswerPeer::getFieldNames($type); + $pos = array_search($name, $names); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setQuestionId($value); + break; + case 2: + $this->setUserId($value); + break; + case 3: + $this->setBody($value); + break; + case 4: + $this->setRelevancyUp($value); + break; + case 5: + $this->setRelevancyDown($value); + break; + case 6: + $this->setCreatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = AnswerPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setQuestionId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setUserId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setBody($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setRelevancyUp($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setRelevancyDown($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(AnswerPeer::DATABASE_NAME); + + if ($this->isColumnModified(AnswerPeer::ID)) $criteria->add(AnswerPeer::ID, $this->id); + if ($this->isColumnModified(AnswerPeer::QUESTION_ID)) $criteria->add(AnswerPeer::QUESTION_ID, $this->question_id); + if ($this->isColumnModified(AnswerPeer::USER_ID)) $criteria->add(AnswerPeer::USER_ID, $this->user_id); + if ($this->isColumnModified(AnswerPeer::BODY)) $criteria->add(AnswerPeer::BODY, $this->body); + if ($this->isColumnModified(AnswerPeer::RELEVANCY_UP)) $criteria->add(AnswerPeer::RELEVANCY_UP, $this->relevancy_up); + if ($this->isColumnModified(AnswerPeer::RELEVANCY_DOWN)) $criteria->add(AnswerPeer::RELEVANCY_DOWN, $this->relevancy_down); + if ($this->isColumnModified(AnswerPeer::CREATED_AT)) $criteria->add(AnswerPeer::CREATED_AT, $this->created_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(AnswerPeer::DATABASE_NAME); + + $criteria->add(AnswerPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of Answer (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setQuestionId($this->question_id); + + $copyObj->setUserId($this->user_id); + + $copyObj->setBody($this->body); + + $copyObj->setRelevancyUp($this->relevancy_up); + + $copyObj->setRelevancyDown($this->relevancy_down); + + $copyObj->setCreatedAt($this->created_at); + + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach($this->getRelevancys() as $relObj) { + $copyObj->addRelevancy($relObj->copy($deepCopy)); + } + + } // if ($deepCopy) + + + $copyObj->setNew(true); + + $copyObj->setId(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return Answer Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return AnswerPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new AnswerPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a Question object. + * + * @param Question $v + * @return void + * @throws PropelException + */ + public function setQuestion($v) + { + + + if ($v === null) { + $this->setQuestionId(NULL); + } else { + $this->setQuestionId($v->getId()); + } + + + $this->aQuestion = $v; + } + + + /** + * Get the associated Question object + * + * @param Connection Optional Connection object. + * @return Question The associated Question object. + * @throws PropelException + */ + public function getQuestion($con = null) + { + // include the related Peer class + include_once 'model/om/BaseQuestionPeer.php'; + + if ($this->aQuestion === null && ($this->question_id !== null)) { + + $this->aQuestion = QuestionPeer::retrieveByPK($this->question_id, $con); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + $obj = QuestionPeer::retrieveByPK($this->question_id, $con); + $obj->addQuestions($this); + */ + } + return $this->aQuestion; + } + + /** + * Declares an association between this object and a User object. + * + * @param User $v + * @return void + * @throws PropelException + */ + public function setUser($v) + { + + + if ($v === null) { + $this->setUserId(NULL); + } else { + $this->setUserId($v->getId()); + } + + + $this->aUser = $v; + } + + + /** + * Get the associated User object + * + * @param Connection Optional Connection object. + * @return User The associated User object. + * @throws PropelException + */ + public function getUser($con = null) + { + // include the related Peer class + include_once 'model/om/BaseUserPeer.php'; + + if ($this->aUser === null && ($this->user_id !== null)) { + + $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + $obj = UserPeer::retrieveByPK($this->user_id, $con); + $obj->addUsers($this); + */ + } + return $this->aUser; + } + + /** + * Temporary storage of collRelevancys to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + * @return void + */ + public function initRelevancys() + { + if ($this->collRelevancys === null) { + $this->collRelevancys = array(); + } + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Answer has previously + * been saved, it will retrieve related Relevancys from storage. + * If this Answer is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @param Connection $con + * @param Criteria $criteria + * @throws PropelException + */ + public function getRelevancys($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseRelevancyPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collRelevancys === null) { + if ($this->isNew()) { + $this->collRelevancys = array(); + } else { + + $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); + + RelevancyPeer::addSelectColumns($criteria); + $this->collRelevancys = RelevancyPeer::doSelect($criteria, $con); + } + } else { + // criteria has no effect for a new object + if (!$this->isNew()) { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + + $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); + + RelevancyPeer::addSelectColumns($criteria); + if (!isset($this->lastRelevancyCriteria) || !$this->lastRelevancyCriteria->equals($criteria)) { + $this->collRelevancys = RelevancyPeer::doSelect($criteria, $con); + } + } + } + $this->lastRelevancyCriteria = $criteria; + return $this->collRelevancys; + } + + /** + * Returns the number of related Relevancys. + * + * @param Criteria $criteria + * @param Connection $con + * @throws PropelException + */ + public function countRelevancys($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseRelevancyPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); + + return RelevancyPeer::doCount($criteria, $con); + } + + /** + * Method called to associate a Relevancy object to this object + * through the Relevancy foreign key attribute + * + * @param Relevancy $l Relevancy + * @return void + * @throws PropelException + */ + public function addRelevancy(Relevancy $l) + { + $this->collRelevancys[] = $l; + $l->setAnswer($this); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Answer is new, it will return + * an empty collection; or if this Answer has previously + * been saved, it will retrieve related Relevancys from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Answer. + */ + public function getRelevancysJoinUser($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseRelevancyPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collRelevancys === null) { + if ($this->isNew()) { + $this->collRelevancys = array(); + } else { + + $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); + + $this->collRelevancys = RelevancyPeer::doSelectJoinUser($criteria, $con); + } + } else { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); + + if (!isset($this->lastRelevancyCriteria) || !$this->lastRelevancyCriteria->equals($criteria)) { + $this->collRelevancys = RelevancyPeer::doSelectJoinUser($criteria, $con); + } + } + $this->lastRelevancyCriteria = $criteria; + + return $this->collRelevancys; + } + +} // BaseAnswer Index: /tags/release_day_7/lib/model/om/BaseQuestionPeer.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseQuestionPeer.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseQuestionPeer.php (revision 16) @@ -0,0 +1,804 @@ + array ('Id', 'UserId', 'Title', 'StrippedTitle', 'Body', 'InterestedUsers', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_COLNAME => array (QuestionPeer::ID, QuestionPeer::USER_ID, QuestionPeer::TITLE, QuestionPeer::STRIPPED_TITLE, QuestionPeer::BODY, QuestionPeer::INTERESTED_USERS, QuestionPeer::CREATED_AT, QuestionPeer::UPDATED_AT, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'user_id', 'title', 'stripped_title', 'body', 'interested_users', 'created_at', 'updated_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'UserId' => 1, 'Title' => 2, 'StrippedTitle' => 3, 'Body' => 4, 'InterestedUsers' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + BasePeer::TYPE_COLNAME => array (QuestionPeer::ID => 0, QuestionPeer::USER_ID => 1, QuestionPeer::TITLE => 2, QuestionPeer::STRIPPED_TITLE => 3, QuestionPeer::BODY => 4, QuestionPeer::INTERESTED_USERS => 5, QuestionPeer::CREATED_AT => 6, QuestionPeer::UPDATED_AT => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'user_id' => 1, 'title' => 2, 'stripped_title' => 3, 'body' => 4, 'interested_users' => 5, 'created_at' => 6, 'updated_at' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'model/map/QuestionMapBuilder.php'; + return BasePeer::getMapBuilder('model.map.QuestionMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @todo Consider having template build the array rather than doing it at runtime. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = QuestionPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. QuestionPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return $alias . substr($column, strlen(QuestionPeer::TABLE_NAME)); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(QuestionPeer::ID); + + $criteria->addSelectColumn(QuestionPeer::USER_ID); + + $criteria->addSelectColumn(QuestionPeer::TITLE); + + $criteria->addSelectColumn(QuestionPeer::STRIPPED_TITLE); + + $criteria->addSelectColumn(QuestionPeer::BODY); + + $criteria->addSelectColumn(QuestionPeer::INTERESTED_USERS); + + $criteria->addSelectColumn(QuestionPeer::CREATED_AT); + + $criteria->addSelectColumn(QuestionPeer::UPDATED_AT); + + } + + const COUNT = 'COUNT(ask_question.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT ask_question.ID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(QuestionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(QuestionPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = QuestionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return Question + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = QuestionPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return QuestionPeer::populateObjects(QuestionPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + QuestionPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = QuestionPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + /** + * Returns the number of rows matching criteria, joining the related User table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(QuestionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(QuestionPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(QuestionPeer::USER_ID, UserPeer::ID); + + $rs = QuestionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Question objects pre-filled with their User objects. + * + * @return array Array of Question objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinUser(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + QuestionPeer::addSelectColumns($c); + $startcol = (QuestionPeer::NUM_COLUMNS - QuestionPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + UserPeer::addSelectColumns($c); + + $c->addJoin(QuestionPeer::USER_ID, UserPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = QuestionPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getUser(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + // e.g. $author->addBookRelatedByBookId() + $temp_obj2->addQuestion($obj1); //CHECKME + break; + } + } + if ($newObject) { + $obj2->initQuestions(); + $obj2->addQuestion($obj1); //CHECKME + } + $results[] = $obj1; + } + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining all related tables + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(QuestionPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(QuestionPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(QuestionPeer::USER_ID, UserPeer::ID); + + $rs = QuestionPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Question objects pre-filled with all related objects. + * + * @return array Array of Question objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + QuestionPeer::addSelectColumns($c); + $startcol2 = (QuestionPeer::NUM_COLUMNS - QuestionPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + UserPeer::addSelectColumns($c); + $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; + + $c->addJoin(QuestionPeer::USER_ID, UserPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = QuestionPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + // Add objects for joined User rows + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getUser(); // CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addQuestion($obj1); // CHECKME + break; + } + } + + if ($newObject) { + $obj2->initQuestions(); + $obj2->addQuestion($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return QuestionPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a Question or Criteria object. + * + * @param mixed $values Criteria or Question object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from Question object + } + + $criteria->remove(QuestionPeer::ID); // remove pkey col since this table uses auto-increment + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a Question or Criteria object. + * + * @param mixed $values Criteria or Question object containing data that is used to create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(QuestionPeer::ID); + $selectCriteria->add(QuestionPeer::ID, $criteria->remove(QuestionPeer::ID), $comparison); + + } else { // $values is Question object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the ask_question table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(QuestionPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a Question or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Question object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(QuestionPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof Question) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(QuestionPeer::ID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given Question object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param Question $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(Question $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(QuestionPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(QuestionPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(QuestionPeer::DATABASE_NAME, QuestionPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return Question + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(QuestionPeer::DATABASE_NAME); + + $criteria->add(QuestionPeer::ID, $pk); + + + $v = QuestionPeer::doSelect($criteria, $con); + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(QuestionPeer::ID, $pks, Criteria::IN); + $objs = QuestionPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseQuestionPeer + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseQuestionPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'model/map/QuestionMapBuilder.php'; + Propel::registerMapBuilder('model.map.QuestionMapBuilder'); +} Index: /tags/release_day_7/lib/model/om/BaseRelevancyPeer.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseRelevancyPeer.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseRelevancyPeer.php (revision 16) @@ -0,0 +1,1087 @@ + array ('AnswerId', 'UserId', 'Score', 'CreatedAt', ), + BasePeer::TYPE_COLNAME => array (RelevancyPeer::ANSWER_ID, RelevancyPeer::USER_ID, RelevancyPeer::SCORE, RelevancyPeer::CREATED_AT, ), + BasePeer::TYPE_FIELDNAME => array ('answer_id', 'user_id', 'score', 'created_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('AnswerId' => 0, 'UserId' => 1, 'Score' => 2, 'CreatedAt' => 3, ), + BasePeer::TYPE_COLNAME => array (RelevancyPeer::ANSWER_ID => 0, RelevancyPeer::USER_ID => 1, RelevancyPeer::SCORE => 2, RelevancyPeer::CREATED_AT => 3, ), + BasePeer::TYPE_FIELDNAME => array ('answer_id' => 0, 'user_id' => 1, 'score' => 2, 'created_at' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'model/map/RelevancyMapBuilder.php'; + return BasePeer::getMapBuilder('model.map.RelevancyMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @todo Consider having template build the array rather than doing it at runtime. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = RelevancyPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. RelevancyPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return $alias . substr($column, strlen(RelevancyPeer::TABLE_NAME)); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(RelevancyPeer::ANSWER_ID); + + $criteria->addSelectColumn(RelevancyPeer::USER_ID); + + $criteria->addSelectColumn(RelevancyPeer::SCORE); + + $criteria->addSelectColumn(RelevancyPeer::CREATED_AT); + + } + + const COUNT = 'COUNT(*)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT *)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(RelevancyPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = RelevancyPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return Relevancy + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = RelevancyPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return RelevancyPeer::populateObjects(RelevancyPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + RelevancyPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = RelevancyPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + /** + * Returns the number of rows matching criteria, joining the related Answer table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAnswer(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(RelevancyPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); + + $rs = RelevancyPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Returns the number of rows matching criteria, joining the related User table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(RelevancyPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); + + $rs = RelevancyPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Relevancy objects pre-filled with their Answer objects. + * + * @return array Array of Relevancy objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAnswer(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + RelevancyPeer::addSelectColumns($c); + $startcol = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + AnswerPeer::addSelectColumns($c); + + $c->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = RelevancyPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = AnswerPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getAnswer(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + // e.g. $author->addBookRelatedByBookId() + $temp_obj2->addRelevancy($obj1); //CHECKME + break; + } + } + if ($newObject) { + $obj2->initRelevancys(); + $obj2->addRelevancy($obj1); //CHECKME + } + $results[] = $obj1; + } + return $results; + } + + + /** + * Selects a collection of Relevancy objects pre-filled with their User objects. + * + * @return array Array of Relevancy objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinUser(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + RelevancyPeer::addSelectColumns($c); + $startcol = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + UserPeer::addSelectColumns($c); + + $c->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = RelevancyPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getUser(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + // e.g. $author->addBookRelatedByBookId() + $temp_obj2->addRelevancy($obj1); //CHECKME + break; + } + } + if ($newObject) { + $obj2->initRelevancys(); + $obj2->addRelevancy($obj1); //CHECKME + } + $results[] = $obj1; + } + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining all related tables + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(RelevancyPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); + + $criteria->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); + + $rs = RelevancyPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Relevancy objects pre-filled with all related objects. + * + * @return array Array of Relevancy objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + RelevancyPeer::addSelectColumns($c); + $startcol2 = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + AnswerPeer::addSelectColumns($c); + $startcol3 = $startcol2 + AnswerPeer::NUM_COLUMNS; + + UserPeer::addSelectColumns($c); + $startcol4 = $startcol3 + UserPeer::NUM_COLUMNS; + + $c->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); + + $c->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = RelevancyPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + // Add objects for joined Answer rows + + $omClass = AnswerPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getAnswer(); // CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addRelevancy($obj1); // CHECKME + break; + } + } + + if ($newObject) { + $obj2->initRelevancys(); + $obj2->addRelevancy($obj1); + } + + + // Add objects for joined User rows + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj3 = new $cls(); + $obj3->hydrate($rs, $startcol3); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj3 = $temp_obj1->getUser(); // CHECKME + if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { + $newObject = false; + $temp_obj3->addRelevancy($obj1); // CHECKME + break; + } + } + + if ($newObject) { + $obj3->initRelevancys(); + $obj3->addRelevancy($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related Answer table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptAnswer(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(RelevancyPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); + + $rs = RelevancyPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Returns the number of rows matching criteria, joining the related User table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(RelevancyPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(RelevancyPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); + + $rs = RelevancyPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Relevancy objects pre-filled with all related objects except Answer. + * + * @return array Array of Relevancy objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptAnswer(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + // $c->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + RelevancyPeer::addSelectColumns($c); + $startcol2 = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + UserPeer::addSelectColumns($c); + $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; + + $c->addJoin(RelevancyPeer::USER_ID, UserPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = RelevancyPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getUser(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addRelevancy($obj1); + break; + } + } + + if ($newObject) { + $obj2->initRelevancys(); + $obj2->addRelevancy($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + /** + * Selects a collection of Relevancy objects pre-filled with all related objects except User. + * + * @return array Array of Relevancy objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + // $c->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + RelevancyPeer::addSelectColumns($c); + $startcol2 = (RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + AnswerPeer::addSelectColumns($c); + $startcol3 = $startcol2 + AnswerPeer::NUM_COLUMNS; + + $c->addJoin(RelevancyPeer::ANSWER_ID, AnswerPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = RelevancyPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = AnswerPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getAnswer(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addRelevancy($obj1); + break; + } + } + + if ($newObject) { + $obj2->initRelevancys(); + $obj2->addRelevancy($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return RelevancyPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a Relevancy or Criteria object. + * + * @param mixed $values Criteria or Relevancy object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from Relevancy object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a Relevancy or Criteria object. + * + * @param mixed $values Criteria or Relevancy object containing data that is used to create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + } else { // $values is Relevancy object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the ask_relevancy table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(RelevancyPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a Relevancy or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Relevancy object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(RelevancyPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof Relevancy) { + + $criteria = $values->buildCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey + // values + if(count($values) == count($values, COUNT_RECURSIVE)) + { + // array is not multi-dimensional + $values = array($values); + } + $vals = array(); + foreach($values as $value) + { + + } + + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given Relevancy object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param Relevancy $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(Relevancy $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(RelevancyPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(RelevancyPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(RelevancyPeer::DATABASE_NAME, RelevancyPeer::TABLE_NAME, $columns); + } + +} // BaseRelevancyPeer + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseRelevancyPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'model/map/RelevancyMapBuilder.php'; + Propel::registerMapBuilder('model.map.RelevancyMapBuilder'); +} Index: /tags/release_day_7/lib/model/om/BaseQuestion.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseQuestion.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseQuestion.php (revision 16) @@ -0,0 +1,1338 @@ +id; + } + + /** + * Get the [user_id] column value. + * + * @return int + */ + public function getUserId() + { + + return $this->user_id; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [stripped_title] column value. + * + * @return string + */ + public function getStrippedTitle() + { + + return $this->stripped_title; + } + + /** + * Get the [body] column value. + * + * @return string + */ + public function getBody() + { + + return $this->body; + } + + /** + * Get the [interested_users] column value. + * + * @return int + */ + public function getInterestedUsers() + { + + return $this->interested_users; + } + + /** + * Get the [optionally formatted] [created_at] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + + if ($this->created_at === null || $this->created_at === '') { + return null; + } elseif (!is_int($this->created_at)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->created_at); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); + } + } else { + $ts = $this->created_at; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [optionally formatted] [updated_at] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getUpdatedAt($format = 'Y-m-d H:i:s') + { + + if ($this->updated_at === null || $this->updated_at === '') { + return null; + } elseif (!is_int($this->updated_at)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->updated_at); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true)); + } + } else { + $ts = $this->updated_at; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return void + */ + public function setId($v) + { + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = QuestionPeer::ID; + } + + } // setId() + + /** + * Set the value of [user_id] column. + * + * @param int $v new value + * @return void + */ + public function setUserId($v) + { + + if ($this->user_id !== $v) { + $this->user_id = $v; + $this->modifiedColumns[] = QuestionPeer::USER_ID; + } + + if ($this->aUser !== null && $this->aUser->getId() !== $v) { + $this->aUser = null; + } + + } // setUserId() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return void + */ + public function setTitle($v) + { + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = QuestionPeer::TITLE; + } + + } // setTitle() + + /** + * Set the value of [stripped_title] column. + * + * @param string $v new value + * @return void + */ + public function setStrippedTitle($v) + { + + if ($this->stripped_title !== $v) { + $this->stripped_title = $v; + $this->modifiedColumns[] = QuestionPeer::STRIPPED_TITLE; + } + + } // setStrippedTitle() + + /** + * Set the value of [body] column. + * + * @param string $v new value + * @return void + */ + public function setBody($v) + { + + if ($this->body !== $v) { + $this->body = $v; + $this->modifiedColumns[] = QuestionPeer::BODY; + } + + } // setBody() + + /** + * Set the value of [interested_users] column. + * + * @param int $v new value + * @return void + */ + public function setInterestedUsers($v) + { + + if ($this->interested_users !== $v || $v === 0) { + $this->interested_users = $v; + $this->modifiedColumns[] = QuestionPeer::INTERESTED_USERS; + } + + } // setInterestedUsers() + + /** + * Set the value of [created_at] column. + * + * @param int $v new value + * @return void + */ + public function setCreatedAt($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->created_at !== $ts) { + $this->created_at = $ts; + $this->modifiedColumns[] = QuestionPeer::CREATED_AT; + } + + } // setCreatedAt() + + /** + * Set the value of [updated_at] column. + * + * @param int $v new value + * @return void + */ + public function setUpdatedAt($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->updated_at !== $ts) { + $this->updated_at = $ts; + $this->modifiedColumns[] = QuestionPeer::UPDATED_AT; + } + + } // setUpdatedAt() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->user_id = $rs->getInt($startcol + 1); + + $this->title = $rs->getString($startcol + 2); + + $this->stripped_title = $rs->getString($startcol + 3); + + $this->body = $rs->getString($startcol + 4); + + $this->interested_users = $rs->getInt($startcol + 5); + + $this->created_at = $rs->getTimestamp($startcol + 6, null); + + $this->updated_at = $rs->getTimestamp($startcol + 7, null); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 8; // 8 = QuestionPeer::NUM_COLUMNS - QuestionPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating Question object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(QuestionPeer::DATABASE_NAME); + } + + try { + $con->begin(); + QuestionPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isNew()) + { + $this->setCreatedAt(time()); + } + $this->setUpdatedAt(time()); + + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(QuestionPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // We call the save method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aUser !== null) { + if ($this->aUser->isModified()) { + $affectedRows += $this->aUser->save($con); + } + $this->setUser($this->aUser); + } + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = QuestionPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setId($pk); //[IMV] update autoincrement primary key + + $this->setNew(false); + } else { + $affectedRows += QuestionPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + if ($this->collAnswers !== null) { + foreach($this->collAnswers as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collInterests !== null) { + foreach($this->collInterests as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * + * @return mixed true if all columns pass validation + * or an array of ValidationFailed objects for columns that fail. + * @see doValidate() + */ + public function validate($columns = null) + { + if ($columns) { + return QuestionPeer::doValidate($this, $columns); + } + return $this->doValidate(); + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate() + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + // We call the validate method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aUser !== null) { + if (($retval = $this->aUser->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + + + if (($retval = QuestionPeer::doValidate($this)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collAnswers !== null) { + foreach($this->collAnswers as $referrerFK) { + if (($retval = $referrerFK->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + } + + if ($this->collInterests !== null) { + foreach($this->collInterests as $referrerFK) { + if (($retval = $referrerFK->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + } + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $names = QuestionPeer::getFieldNames($type); + $pos = QuestionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getUserId(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getStrippedTitle(); + break; + case 4: + return $this->getBody(); + break; + case 5: + return $this->getInterestedUsers(); + break; + case 6: + return $this->getCreatedAt(); + break; + case 7: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = QuestionPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getUserId(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getStrippedTitle(), + $keys[4] => $this->getBody(), + $keys[5] => $this->getInterestedUsers(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $names = QuestionPeer::getFieldNames($type); + $pos = array_search($name, $names); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setUserId($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setStrippedTitle($value); + break; + case 4: + $this->setBody($value); + break; + case 5: + $this->setInterestedUsers($value); + break; + case 6: + $this->setCreatedAt($value); + break; + case 7: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = QuestionPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setStrippedTitle($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setBody($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setInterestedUsers($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(QuestionPeer::DATABASE_NAME); + + if ($this->isColumnModified(QuestionPeer::ID)) $criteria->add(QuestionPeer::ID, $this->id); + if ($this->isColumnModified(QuestionPeer::USER_ID)) $criteria->add(QuestionPeer::USER_ID, $this->user_id); + if ($this->isColumnModified(QuestionPeer::TITLE)) $criteria->add(QuestionPeer::TITLE, $this->title); + if ($this->isColumnModified(QuestionPeer::STRIPPED_TITLE)) $criteria->add(QuestionPeer::STRIPPED_TITLE, $this->stripped_title); + if ($this->isColumnModified(QuestionPeer::BODY)) $criteria->add(QuestionPeer::BODY, $this->body); + if ($this->isColumnModified(QuestionPeer::INTERESTED_USERS)) $criteria->add(QuestionPeer::INTERESTED_USERS, $this->interested_users); + if ($this->isColumnModified(QuestionPeer::CREATED_AT)) $criteria->add(QuestionPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(QuestionPeer::UPDATED_AT)) $criteria->add(QuestionPeer::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(QuestionPeer::DATABASE_NAME); + + $criteria->add(QuestionPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of Question (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setUserId($this->user_id); + + $copyObj->setTitle($this->title); + + $copyObj->setStrippedTitle($this->stripped_title); + + $copyObj->setBody($this->body); + + $copyObj->setInterestedUsers($this->interested_users); + + $copyObj->setCreatedAt($this->created_at); + + $copyObj->setUpdatedAt($this->updated_at); + + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach($this->getAnswers() as $relObj) { + $copyObj->addAnswer($relObj->copy($deepCopy)); + } + + foreach($this->getInterests() as $relObj) { + $copyObj->addInterest($relObj->copy($deepCopy)); + } + + } // if ($deepCopy) + + + $copyObj->setNew(true); + + $copyObj->setId(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return Question Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return QuestionPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new QuestionPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a User object. + * + * @param User $v + * @return void + * @throws PropelException + */ + public function setUser($v) + { + + + if ($v === null) { + $this->setUserId(NULL); + } else { + $this->setUserId($v->getId()); + } + + + $this->aUser = $v; + } + + + /** + * Get the associated User object + * + * @param Connection Optional Connection object. + * @return User The associated User object. + * @throws PropelException + */ + public function getUser($con = null) + { + // include the related Peer class + include_once 'model/om/BaseUserPeer.php'; + + if ($this->aUser === null && ($this->user_id !== null)) { + + $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + $obj = UserPeer::retrieveByPK($this->user_id, $con); + $obj->addUsers($this); + */ + } + return $this->aUser; + } + + /** + * Temporary storage of collAnswers to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + * @return void + */ + public function initAnswers() + { + if ($this->collAnswers === null) { + $this->collAnswers = array(); + } + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Question has previously + * been saved, it will retrieve related Answers from storage. + * If this Question is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @param Connection $con + * @param Criteria $criteria + * @throws PropelException + */ + public function getAnswers($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseAnswerPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAnswers === null) { + if ($this->isNew()) { + $this->collAnswers = array(); + } else { + + $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); + + AnswerPeer::addSelectColumns($criteria); + $this->collAnswers = AnswerPeer::doSelect($criteria, $con); + } + } else { + // criteria has no effect for a new object + if (!$this->isNew()) { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + + $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); + + AnswerPeer::addSelectColumns($criteria); + if (!isset($this->lastAnswerCriteria) || !$this->lastAnswerCriteria->equals($criteria)) { + $this->collAnswers = AnswerPeer::doSelect($criteria, $con); + } + } + } + $this->lastAnswerCriteria = $criteria; + return $this->collAnswers; + } + + /** + * Returns the number of related Answers. + * + * @param Criteria $criteria + * @param Connection $con + * @throws PropelException + */ + public function countAnswers($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseAnswerPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); + + return AnswerPeer::doCount($criteria, $con); + } + + /** + * Method called to associate a Answer object to this object + * through the Answer foreign key attribute + * + * @param Answer $l Answer + * @return void + * @throws PropelException + */ + public function addAnswer(Answer $l) + { + $this->collAnswers[] = $l; + $l->setQuestion($this); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Question is new, it will return + * an empty collection; or if this Question has previously + * been saved, it will retrieve related Answers from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Question. + */ + public function getAnswersJoinUser($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseAnswerPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAnswers === null) { + if ($this->isNew()) { + $this->collAnswers = array(); + } else { + + $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); + + $this->collAnswers = AnswerPeer::doSelectJoinUser($criteria, $con); + } + } else { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); + + if (!isset($this->lastAnswerCriteria) || !$this->lastAnswerCriteria->equals($criteria)) { + $this->collAnswers = AnswerPeer::doSelectJoinUser($criteria, $con); + } + } + $this->lastAnswerCriteria = $criteria; + + return $this->collAnswers; + } + + /** + * Temporary storage of collInterests to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + * @return void + */ + public function initInterests() + { + if ($this->collInterests === null) { + $this->collInterests = array(); + } + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Question has previously + * been saved, it will retrieve related Interests from storage. + * If this Question is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @param Connection $con + * @param Criteria $criteria + * @throws PropelException + */ + public function getInterests($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseInterestPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collInterests === null) { + if ($this->isNew()) { + $this->collInterests = array(); + } else { + + $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); + + InterestPeer::addSelectColumns($criteria); + $this->collInterests = InterestPeer::doSelect($criteria, $con); + } + } else { + // criteria has no effect for a new object + if (!$this->isNew()) { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + + $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); + + InterestPeer::addSelectColumns($criteria); + if (!isset($this->lastInterestCriteria) || !$this->lastInterestCriteria->equals($criteria)) { + $this->collInterests = InterestPeer::doSelect($criteria, $con); + } + } + } + $this->lastInterestCriteria = $criteria; + return $this->collInterests; + } + + /** + * Returns the number of related Interests. + * + * @param Criteria $criteria + * @param Connection $con + * @throws PropelException + */ + public function countInterests($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseInterestPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); + + return InterestPeer::doCount($criteria, $con); + } + + /** + * Method called to associate a Interest object to this object + * through the Interest foreign key attribute + * + * @param Interest $l Interest + * @return void + * @throws PropelException + */ + public function addInterest(Interest $l) + { + $this->collInterests[] = $l; + $l->setQuestion($this); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Question is new, it will return + * an empty collection; or if this Question has previously + * been saved, it will retrieve related Interests from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Question. + */ + public function getInterestsJoinUser($criteria = null, $con = null) + { + // include the Peer class + include_once 'model/om/BaseInterestPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collInterests === null) { + if ($this->isNew()) { + $this->collInterests = array(); + } else { + + $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); + + $this->collInterests = InterestPeer::doSelectJoinUser($criteria, $con); + } + } else { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + + $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); + + if (!isset($this->lastInterestCriteria) || !$this->lastInterestCriteria->equals($criteria)) { + $this->collInterests = InterestPeer::doSelectJoinUser($criteria, $con); + } + } + $this->lastInterestCriteria = $criteria; + + return $this->collInterests; + } + +} // BaseQuestion Index: /tags/release_day_7/lib/model/om/BaseRelevancy.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseRelevancy.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseRelevancy.php (revision 16) @@ -0,0 +1,813 @@ +answer_id; + } + + /** + * Get the [user_id] column value. + * + * @return int + */ + public function getUserId() + { + + return $this->user_id; + } + + /** + * Get the [score] column value. + * + * @return int + */ + public function getScore() + { + + return $this->score; + } + + /** + * Get the [optionally formatted] [created_at] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + + if ($this->created_at === null || $this->created_at === '') { + return null; + } elseif (!is_int($this->created_at)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->created_at); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); + } + } else { + $ts = $this->created_at; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Set the value of [answer_id] column. + * + * @param int $v new value + * @return void + */ + public function setAnswerId($v) + { + + if ($this->answer_id !== $v) { + $this->answer_id = $v; + $this->modifiedColumns[] = RelevancyPeer::ANSWER_ID; + } + + if ($this->aAnswer !== null && $this->aAnswer->getId() !== $v) { + $this->aAnswer = null; + } + + } // setAnswerId() + + /** + * Set the value of [user_id] column. + * + * @param int $v new value + * @return void + */ + public function setUserId($v) + { + + if ($this->user_id !== $v) { + $this->user_id = $v; + $this->modifiedColumns[] = RelevancyPeer::USER_ID; + } + + if ($this->aUser !== null && $this->aUser->getId() !== $v) { + $this->aUser = null; + } + + } // setUserId() + + /** + * Set the value of [score] column. + * + * @param int $v new value + * @return void + */ + public function setScore($v) + { + + if ($this->score !== $v) { + $this->score = $v; + $this->modifiedColumns[] = RelevancyPeer::SCORE; + } + + } // setScore() + + /** + * Set the value of [created_at] column. + * + * @param int $v new value + * @return void + */ + public function setCreatedAt($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->created_at !== $ts) { + $this->created_at = $ts; + $this->modifiedColumns[] = RelevancyPeer::CREATED_AT; + } + + } // setCreatedAt() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->answer_id = $rs->getInt($startcol + 0); + + $this->user_id = $rs->getInt($startcol + 1); + + $this->score = $rs->getInt($startcol + 2); + + $this->created_at = $rs->getTimestamp($startcol + 3, null); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 4; // 4 = RelevancyPeer::NUM_COLUMNS - RelevancyPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating Relevancy object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(RelevancyPeer::DATABASE_NAME); + } + + try { + $con->begin(); + RelevancyPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isNew()) + { + $this->setCreatedAt(time()); + } + + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(RelevancyPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // We call the save method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aAnswer !== null) { + if ($this->aAnswer->isModified()) { + $affectedRows += $this->aAnswer->save($con); + } + $this->setAnswer($this->aAnswer); + } + + if ($this->aUser !== null) { + if ($this->aUser->isModified()) { + $affectedRows += $this->aUser->save($con); + } + $this->setUser($this->aUser); + } + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = RelevancyPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += RelevancyPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * + * @return mixed true if all columns pass validation + * or an array of ValidationFailed objects for columns that fail. + * @see doValidate() + */ + public function validate($columns = null) + { + if ($columns) { + return RelevancyPeer::doValidate($this, $columns); + } + return $this->doValidate(); + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate() + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + // We call the validate method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aAnswer !== null) { + if (($retval = $this->aAnswer->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + + if ($this->aUser !== null) { + if (($retval = $this->aUser->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + + + if (($retval = RelevancyPeer::doValidate($this)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $names = RelevancyPeer::getFieldNames($type); + $pos = RelevancyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getAnswerId(); + break; + case 1: + return $this->getUserId(); + break; + case 2: + return $this->getScore(); + break; + case 3: + return $this->getCreatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = RelevancyPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getAnswerId(), + $keys[1] => $this->getUserId(), + $keys[2] => $this->getScore(), + $keys[3] => $this->getCreatedAt(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $names = RelevancyPeer::getFieldNames($type); + $pos = array_search($name, $names); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setAnswerId($value); + break; + case 1: + $this->setUserId($value); + break; + case 2: + $this->setScore($value); + break; + case 3: + $this->setCreatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = RelevancyPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setAnswerId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setScore($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(RelevancyPeer::DATABASE_NAME); + + if ($this->isColumnModified(RelevancyPeer::ANSWER_ID)) $criteria->add(RelevancyPeer::ANSWER_ID, $this->answer_id); + if ($this->isColumnModified(RelevancyPeer::USER_ID)) $criteria->add(RelevancyPeer::USER_ID, $this->user_id); + if ($this->isColumnModified(RelevancyPeer::SCORE)) $criteria->add(RelevancyPeer::SCORE, $this->score); + if ($this->isColumnModified(RelevancyPeer::CREATED_AT)) $criteria->add(RelevancyPeer::CREATED_AT, $this->created_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(RelevancyPeer::DATABASE_NAME); + + + return $criteria; + } + + /** + * Returns NULL since this table doesn't have a primary key. + * This method exists only for BC and is deprecated! + * @return null + */ + public function getPrimaryKey() + { + return null; + } + + /** + * Dummy primary key setter. + * + * This function only exists to preserve backwards compatibility. It is no longer + * needed or required by the Persistent interface. It will be removed in next BC-breaking + * release of Propel. + * + * @deprecated + */ + public function setPrimaryKey($pk) + { + // do nothing, because this object doesn't have any primary keys + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of Relevancy (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setAnswerId($this->answer_id); + + $copyObj->setUserId($this->user_id); + + $copyObj->setScore($this->score); + + $copyObj->setCreatedAt($this->created_at); + + + $copyObj->setNew(true); + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return Relevancy Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return RelevancyPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new RelevancyPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a Answer object. + * + * @param Answer $v + * @return void + * @throws PropelException + */ + public function setAnswer($v) + { + + + if ($v === null) { + $this->setAnswerId(NULL); + } else { + $this->setAnswerId($v->getId()); + } + + + $this->aAnswer = $v; + } + + + /** + * Get the associated Answer object + * + * @param Connection Optional Connection object. + * @return Answer The associated Answer object. + * @throws PropelException + */ + public function getAnswer($con = null) + { + // include the related Peer class + include_once 'model/om/BaseAnswerPeer.php'; + + if ($this->aAnswer === null && ($this->answer_id !== null)) { + + $this->aAnswer = AnswerPeer::retrieveByPK($this->answer_id, $con); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + $obj = AnswerPeer::retrieveByPK($this->answer_id, $con); + $obj->addAnswers($this); + */ + } + return $this->aAnswer; + } + + /** + * Declares an association between this object and a User object. + * + * @param User $v + * @return void + * @throws PropelException + */ + public function setUser($v) + { + + + if ($v === null) { + $this->setUserId(NULL); + } else { + $this->setUserId($v->getId()); + } + + + $this->aUser = $v; + } + + + /** + * Get the associated User object + * + * @param Connection Optional Connection object. + * @return User The associated User object. + * @throws PropelException + */ + public function getUser($con = null) + { + // include the related Peer class + include_once 'model/om/BaseUserPeer.php'; + + if ($this->aUser === null && ($this->user_id !== null)) { + + $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + $obj = UserPeer::retrieveByPK($this->user_id, $con); + $obj->addUsers($this); + */ + } + return $this->aUser; + } + +} // BaseRelevancy Index: /tags/release_day_7/lib/model/om/BaseInterestPeer.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseInterestPeer.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseInterestPeer.php (revision 16) @@ -0,0 +1,1110 @@ + array ('QuestionId', 'UserId', 'CreatedAt', ), + BasePeer::TYPE_COLNAME => array (InterestPeer::QUESTION_ID, InterestPeer::USER_ID, InterestPeer::CREATED_AT, ), + BasePeer::TYPE_FIELDNAME => array ('question_id', 'user_id', 'created_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('QuestionId' => 0, 'UserId' => 1, 'CreatedAt' => 2, ), + BasePeer::TYPE_COLNAME => array (InterestPeer::QUESTION_ID => 0, InterestPeer::USER_ID => 1, InterestPeer::CREATED_AT => 2, ), + BasePeer::TYPE_FIELDNAME => array ('question_id' => 0, 'user_id' => 1, 'created_at' => 2, ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'model/map/InterestMapBuilder.php'; + return BasePeer::getMapBuilder('model.map.InterestMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @todo Consider having template build the array rather than doing it at runtime. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = InterestPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. InterestPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return $alias . substr($column, strlen(InterestPeer::TABLE_NAME)); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(InterestPeer::QUESTION_ID); + + $criteria->addSelectColumn(InterestPeer::USER_ID); + + $criteria->addSelectColumn(InterestPeer::CREATED_AT); + + } + + const COUNT = 'COUNT(ask_interest.QUESTION_ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT ask_interest.QUESTION_ID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(InterestPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = InterestPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return Interest + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = InterestPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return InterestPeer::populateObjects(InterestPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + InterestPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = InterestPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + /** + * Returns the number of rows matching criteria, joining the related Question table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinQuestion(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(InterestPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(InterestPeer::QUESTION_ID, QuestionPeer::ID); + + $rs = InterestPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Returns the number of rows matching criteria, joining the related User table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(InterestPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(InterestPeer::USER_ID, UserPeer::ID); + + $rs = InterestPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Interest objects pre-filled with their Question objects. + * + * @return array Array of Interest objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinQuestion(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + InterestPeer::addSelectColumns($c); + $startcol = (InterestPeer::NUM_COLUMNS - InterestPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + QuestionPeer::addSelectColumns($c); + + $c->addJoin(InterestPeer::QUESTION_ID, QuestionPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = InterestPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = QuestionPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getQuestion(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + // e.g. $author->addBookRelatedByBookId() + $temp_obj2->addInterest($obj1); //CHECKME + break; + } + } + if ($newObject) { + $obj2->initInterests(); + $obj2->addInterest($obj1); //CHECKME + } + $results[] = $obj1; + } + return $results; + } + + + /** + * Selects a collection of Interest objects pre-filled with their User objects. + * + * @return array Array of Interest objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinUser(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + InterestPeer::addSelectColumns($c); + $startcol = (InterestPeer::NUM_COLUMNS - InterestPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + UserPeer::addSelectColumns($c); + + $c->addJoin(InterestPeer::USER_ID, UserPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = InterestPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getUser(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + // e.g. $author->addBookRelatedByBookId() + $temp_obj2->addInterest($obj1); //CHECKME + break; + } + } + if ($newObject) { + $obj2->initInterests(); + $obj2->addInterest($obj1); //CHECKME + } + $results[] = $obj1; + } + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining all related tables + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(InterestPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(InterestPeer::QUESTION_ID, QuestionPeer::ID); + + $criteria->addJoin(InterestPeer::USER_ID, UserPeer::ID); + + $rs = InterestPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Interest objects pre-filled with all related objects. + * + * @return array Array of Interest objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + InterestPeer::addSelectColumns($c); + $startcol2 = (InterestPeer::NUM_COLUMNS - InterestPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + QuestionPeer::addSelectColumns($c); + $startcol3 = $startcol2 + QuestionPeer::NUM_COLUMNS; + + UserPeer::addSelectColumns($c); + $startcol4 = $startcol3 + UserPeer::NUM_COLUMNS; + + $c->addJoin(InterestPeer::QUESTION_ID, QuestionPeer::ID); + + $c->addJoin(InterestPeer::USER_ID, UserPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = InterestPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + // Add objects for joined Question rows + + $omClass = QuestionPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getQuestion(); // CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addInterest($obj1); // CHECKME + break; + } + } + + if ($newObject) { + $obj2->initInterests(); + $obj2->addInterest($obj1); + } + + + // Add objects for joined User rows + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj3 = new $cls(); + $obj3->hydrate($rs, $startcol3); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj3 = $temp_obj1->getUser(); // CHECKME + if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { + $newObject = false; + $temp_obj3->addInterest($obj1); // CHECKME + break; + } + } + + if ($newObject) { + $obj3->initInterests(); + $obj3->addInterest($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related Question table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptQuestion(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(InterestPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(InterestPeer::USER_ID, UserPeer::ID); + + $rs = InterestPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Returns the number of rows matching criteria, joining the related User table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(InterestPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(InterestPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(InterestPeer::QUESTION_ID, QuestionPeer::ID); + + $rs = InterestPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Interest objects pre-filled with all related objects except Question. + * + * @return array Array of Interest objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptQuestion(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + // $c->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + InterestPeer::addSelectColumns($c); + $startcol2 = (InterestPeer::NUM_COLUMNS - InterestPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + UserPeer::addSelectColumns($c); + $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; + + $c->addJoin(InterestPeer::USER_ID, UserPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = InterestPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getUser(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addInterest($obj1); + break; + } + } + + if ($newObject) { + $obj2->initInterests(); + $obj2->addInterest($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + /** + * Selects a collection of Interest objects pre-filled with all related objects except User. + * + * @return array Array of Interest objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + // $c->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + InterestPeer::addSelectColumns($c); + $startcol2 = (InterestPeer::NUM_COLUMNS - InterestPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + QuestionPeer::addSelectColumns($c); + $startcol3 = $startcol2 + QuestionPeer::NUM_COLUMNS; + + $c->addJoin(InterestPeer::QUESTION_ID, QuestionPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = InterestPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = QuestionPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getQuestion(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addInterest($obj1); + break; + } + } + + if ($newObject) { + $obj2->initInterests(); + $obj2->addInterest($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return InterestPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a Interest or Criteria object. + * + * @param mixed $values Criteria or Interest object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from Interest object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a Interest or Criteria object. + * + * @param mixed $values Criteria or Interest object containing data that is used to create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(InterestPeer::QUESTION_ID); + $selectCriteria->add(InterestPeer::QUESTION_ID, $criteria->remove(InterestPeer::QUESTION_ID), $comparison); + + $comparison = $criteria->getComparison(InterestPeer::USER_ID); + $selectCriteria->add(InterestPeer::USER_ID, $criteria->remove(InterestPeer::USER_ID), $comparison); + + } else { // $values is Interest object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the ask_interest table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(InterestPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a Interest or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Interest object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(InterestPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof Interest) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey + // values + if(count($values) == count($values, COUNT_RECURSIVE)) + { + // array is not multi-dimensional + $values = array($values); + } + $vals = array(); + foreach($values as $value) + { + + $vals[0][] = $value[0]; + $vals[1][] = $value[1]; + } + + $criteria->add(InterestPeer::QUESTION_ID, $vals[0], Criteria::IN); + $criteria->add(InterestPeer::USER_ID, $vals[1], Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given Interest object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param Interest $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(Interest $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(InterestPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(InterestPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(InterestPeer::DATABASE_NAME, InterestPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve object using using composite pkey values. + * @param int $question_id + @param int $user_id + + * @param Connection $con + * @return Interest + */ + public static function retrieveByPK( $question_id, $user_id, $con = null) { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $criteria = new Criteria(); + $criteria->add(InterestPeer::QUESTION_ID, $question_id); + $criteria->add(InterestPeer::USER_ID, $user_id); + $v = InterestPeer::doSelect($criteria, $con); + return !empty($v) ? $v[0] : null; + } +} // BaseInterestPeer + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseInterestPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'model/map/InterestMapBuilder.php'; + Propel::registerMapBuilder('model.map.InterestMapBuilder'); +} Index: /tags/release_day_7/lib/model/om/BaseUserPeer.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseUserPeer.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseUserPeer.php (revision 16) @@ -0,0 +1,601 @@ + array ('Id', 'Nickname', 'FirstName', 'LastName', 'Email', 'Sha1Password', 'Salt', 'CreatedAt', ), + BasePeer::TYPE_COLNAME => array (UserPeer::ID, UserPeer::NICKNAME, UserPeer::FIRST_NAME, UserPeer::LAST_NAME, UserPeer::EMAIL, UserPeer::SHA1_PASSWORD, UserPeer::SALT, UserPeer::CREATED_AT, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'nickname', 'first_name', 'last_name', 'email', 'sha1_password', 'salt', 'created_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Nickname' => 1, 'FirstName' => 2, 'LastName' => 3, 'Email' => 4, 'Sha1Password' => 5, 'Salt' => 6, 'CreatedAt' => 7, ), + BasePeer::TYPE_COLNAME => array (UserPeer::ID => 0, UserPeer::NICKNAME => 1, UserPeer::FIRST_NAME => 2, UserPeer::LAST_NAME => 3, UserPeer::EMAIL => 4, UserPeer::SHA1_PASSWORD => 5, UserPeer::SALT => 6, UserPeer::CREATED_AT => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'nickname' => 1, 'first_name' => 2, 'last_name' => 3, 'email' => 4, 'sha1_password' => 5, 'salt' => 6, 'created_at' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'model/map/UserMapBuilder.php'; + return BasePeer::getMapBuilder('model.map.UserMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @todo Consider having template build the array rather than doing it at runtime. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = UserPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. UserPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return $alias . substr($column, strlen(UserPeer::TABLE_NAME)); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(UserPeer::ID); + + $criteria->addSelectColumn(UserPeer::NICKNAME); + + $criteria->addSelectColumn(UserPeer::FIRST_NAME); + + $criteria->addSelectColumn(UserPeer::LAST_NAME); + + $criteria->addSelectColumn(UserPeer::EMAIL); + + $criteria->addSelectColumn(UserPeer::SHA1_PASSWORD); + + $criteria->addSelectColumn(UserPeer::SALT); + + $criteria->addSelectColumn(UserPeer::CREATED_AT); + + } + + const COUNT = 'COUNT(ask_user.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT ask_user.ID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(UserPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(UserPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = UserPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return User + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = UserPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return UserPeer::populateObjects(UserPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + UserPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = UserPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return UserPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a User or Criteria object. + * + * @param mixed $values Criteria or User object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from User object + } + + $criteria->remove(UserPeer::ID); // remove pkey col since this table uses auto-increment + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a User or Criteria object. + * + * @param mixed $values Criteria or User object containing data that is used to create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(UserPeer::ID); + $selectCriteria->add(UserPeer::ID, $criteria->remove(UserPeer::ID), $comparison); + + } else { // $values is User object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the ask_user table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(UserPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a User or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or User object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(UserPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof User) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(UserPeer::ID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given User object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param User $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(User $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(UserPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(UserPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(UserPeer::DATABASE_NAME, UserPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return User + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(UserPeer::DATABASE_NAME); + + $criteria->add(UserPeer::ID, $pk); + + + $v = UserPeer::doSelect($criteria, $con); + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(UserPeer::ID, $pks, Criteria::IN); + $objs = UserPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseUserPeer + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseUserPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'model/map/UserMapBuilder.php'; + Propel::registerMapBuilder('model.map.UserMapBuilder'); +} Index: /tags/release_day_7/lib/model/om/BaseAnswerPeer.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseAnswerPeer.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseAnswerPeer.php (revision 16) @@ -0,0 +1,1141 @@ + array ('Id', 'QuestionId', 'UserId', 'Body', 'RelevancyUp', 'RelevancyDown', 'CreatedAt', ), + BasePeer::TYPE_COLNAME => array (AnswerPeer::ID, AnswerPeer::QUESTION_ID, AnswerPeer::USER_ID, AnswerPeer::BODY, AnswerPeer::RELEVANCY_UP, AnswerPeer::RELEVANCY_DOWN, AnswerPeer::CREATED_AT, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'question_id', 'user_id', 'body', 'relevancy_up', 'relevancy_down', 'created_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'QuestionId' => 1, 'UserId' => 2, 'Body' => 3, 'RelevancyUp' => 4, 'RelevancyDown' => 5, 'CreatedAt' => 6, ), + BasePeer::TYPE_COLNAME => array (AnswerPeer::ID => 0, AnswerPeer::QUESTION_ID => 1, AnswerPeer::USER_ID => 2, AnswerPeer::BODY => 3, AnswerPeer::RELEVANCY_UP => 4, AnswerPeer::RELEVANCY_DOWN => 5, AnswerPeer::CREATED_AT => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'question_id' => 1, 'user_id' => 2, 'body' => 3, 'relevancy_up' => 4, 'relevancy_down' => 5, 'created_at' => 6, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'model/map/AnswerMapBuilder.php'; + return BasePeer::getMapBuilder('model.map.AnswerMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @todo Consider having template build the array rather than doing it at runtime. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = AnswerPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. AnswerPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return $alias . substr($column, strlen(AnswerPeer::TABLE_NAME)); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(AnswerPeer::ID); + + $criteria->addSelectColumn(AnswerPeer::QUESTION_ID); + + $criteria->addSelectColumn(AnswerPeer::USER_ID); + + $criteria->addSelectColumn(AnswerPeer::BODY); + + $criteria->addSelectColumn(AnswerPeer::RELEVANCY_UP); + + $criteria->addSelectColumn(AnswerPeer::RELEVANCY_DOWN); + + $criteria->addSelectColumn(AnswerPeer::CREATED_AT); + + } + + const COUNT = 'COUNT(ask_answer.ID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT ask_answer.ID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AnswerPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $rs = AnswerPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return Answer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = AnswerPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return AnswerPeer::populateObjects(AnswerPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + AnswerPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = AnswerPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + + /** + * Returns the number of rows matching criteria, joining the related Question table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinQuestion(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AnswerPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AnswerPeer::QUESTION_ID, QuestionPeer::ID); + + $rs = AnswerPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Returns the number of rows matching criteria, joining the related User table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinUser(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AnswerPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AnswerPeer::USER_ID, UserPeer::ID); + + $rs = AnswerPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Answer objects pre-filled with their Question objects. + * + * @return array Array of Answer objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinQuestion(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AnswerPeer::addSelectColumns($c); + $startcol = (AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + QuestionPeer::addSelectColumns($c); + + $c->addJoin(AnswerPeer::QUESTION_ID, QuestionPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AnswerPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = QuestionPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getQuestion(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + // e.g. $author->addBookRelatedByBookId() + $temp_obj2->addAnswer($obj1); //CHECKME + break; + } + } + if ($newObject) { + $obj2->initAnswers(); + $obj2->addAnswer($obj1); //CHECKME + } + $results[] = $obj1; + } + return $results; + } + + + /** + * Selects a collection of Answer objects pre-filled with their User objects. + * + * @return array Array of Answer objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinUser(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AnswerPeer::addSelectColumns($c); + $startcol = (AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + UserPeer::addSelectColumns($c); + + $c->addJoin(AnswerPeer::USER_ID, UserPeer::ID); + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AnswerPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol); + + $newObject = true; + foreach($results as $temp_obj1) { + $temp_obj2 = $temp_obj1->getUser(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + // e.g. $author->addBookRelatedByBookId() + $temp_obj2->addAnswer($obj1); //CHECKME + break; + } + } + if ($newObject) { + $obj2->initAnswers(); + $obj2->addAnswer($obj1); //CHECKME + } + $results[] = $obj1; + } + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining all related tables + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null) + { + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AnswerPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AnswerPeer::QUESTION_ID, QuestionPeer::ID); + + $criteria->addJoin(AnswerPeer::USER_ID, UserPeer::ID); + + $rs = AnswerPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Answer objects pre-filled with all related objects. + * + * @return array Array of Answer objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAll(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AnswerPeer::addSelectColumns($c); + $startcol2 = (AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + QuestionPeer::addSelectColumns($c); + $startcol3 = $startcol2 + QuestionPeer::NUM_COLUMNS; + + UserPeer::addSelectColumns($c); + $startcol4 = $startcol3 + UserPeer::NUM_COLUMNS; + + $c->addJoin(AnswerPeer::QUESTION_ID, QuestionPeer::ID); + + $c->addJoin(AnswerPeer::USER_ID, UserPeer::ID); + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AnswerPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + + // Add objects for joined Question rows + + $omClass = QuestionPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getQuestion(); // CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addAnswer($obj1); // CHECKME + break; + } + } + + if ($newObject) { + $obj2->initAnswers(); + $obj2->addAnswer($obj1); + } + + + // Add objects for joined User rows + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj3 = new $cls(); + $obj3->hydrate($rs, $startcol3); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj3 = $temp_obj1->getUser(); // CHECKME + if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { + $newObject = false; + $temp_obj3->addAnswer($obj1); // CHECKME + break; + } + } + + if ($newObject) { + $obj3->initAnswers(); + $obj3->addAnswer($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related Question table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptQuestion(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AnswerPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AnswerPeer::USER_ID, UserPeer::ID); + + $rs = AnswerPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Returns the number of rows matching criteria, joining the related User table + * + * @param Criteria $c + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptUser(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(AnswerPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(AnswerPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach($criteria->getGroupByColumns() as $column) + { + $criteria->addSelectColumn($column); + } + + $criteria->addJoin(AnswerPeer::QUESTION_ID, QuestionPeer::ID); + + $rs = AnswerPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + + + /** + * Selects a collection of Answer objects pre-filled with all related objects except Question. + * + * @return array Array of Answer objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptQuestion(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + // $c->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AnswerPeer::addSelectColumns($c); + $startcol2 = (AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + UserPeer::addSelectColumns($c); + $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; + + $c->addJoin(AnswerPeer::USER_ID, UserPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AnswerPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = UserPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getUser(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addAnswer($obj1); + break; + } + } + + if ($newObject) { + $obj2->initAnswers(); + $obj2->addAnswer($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + + /** + * Selects a collection of Answer objects pre-filled with all related objects except User. + * + * @return array Array of Answer objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) + { + $c = clone $c; + + // Set the correct dbName if it has not been overridden + // $c->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($c->getDbName() == Propel::getDefaultDB()) { + $c->setDbName(self::DATABASE_NAME); + } + + AnswerPeer::addSelectColumns($c); + $startcol2 = (AnswerPeer::NUM_COLUMNS - AnswerPeer::NUM_LAZY_LOAD_COLUMNS) + 1; + + QuestionPeer::addSelectColumns($c); + $startcol3 = $startcol2 + QuestionPeer::NUM_COLUMNS; + + $c->addJoin(AnswerPeer::QUESTION_ID, QuestionPeer::ID); + + + $rs = BasePeer::doSelect($c, $con); + $results = array(); + + while($rs->next()) { + + $omClass = AnswerPeer::getOMClass(); + + $cls = Propel::import($omClass); + $obj1 = new $cls(); + $obj1->hydrate($rs); + + $omClass = QuestionPeer::getOMClass(); + + + $cls = Propel::import($omClass); + $obj2 = new $cls(); + $obj2->hydrate($rs, $startcol2); + + $newObject = true; + for ($j=0, $resCount=count($results); $j < $resCount; $j++) { + $temp_obj1 = $results[$j]; + $temp_obj2 = $temp_obj1->getQuestion(); //CHECKME + if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { + $newObject = false; + $temp_obj2->addAnswer($obj1); + break; + } + } + + if ($newObject) { + $obj2->initAnswers(); + $obj2->addAnswer($obj1); + } + + $results[] = $obj1; + } + return $results; + } + + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return AnswerPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a Answer or Criteria object. + * + * @param mixed $values Criteria or Answer object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from Answer object + } + + $criteria->remove(AnswerPeer::ID); // remove pkey col since this table uses auto-increment + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a Answer or Criteria object. + * + * @param mixed $values Criteria or Answer object containing data that is used to create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(AnswerPeer::ID); + $selectCriteria->add(AnswerPeer::ID, $criteria->remove(AnswerPeer::ID), $comparison); + + } else { // $values is Answer object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the ask_answer table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(AnswerPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a Answer or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Answer object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(AnswerPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof Answer) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(AnswerPeer::ID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given Answer object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param Answer $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(Answer $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(AnswerPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(AnswerPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(AnswerPeer::DATABASE_NAME, AnswerPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return Answer + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(AnswerPeer::DATABASE_NAME); + + $criteria->add(AnswerPeer::ID, $pk); + + + $v = AnswerPeer::doSelect($criteria, $con); + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(AnswerPeer::ID, $pks, Criteria::IN); + $objs = AnswerPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseAnswerPeer + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseAnswerPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'model/map/AnswerMapBuilder.php'; + Propel::registerMapBuilder('model.map.AnswerMapBuilder'); +} Index: /tags/release_day_7/lib/model/om/BaseInterest.php =================================================================== --- /tags/release_day_7/lib/model/om/BaseInterest.php (revision 16) +++ /tags/release_day_7/lib/model/om/BaseInterest.php (revision 16) @@ -0,0 +1,775 @@ +question_id; + } + + /** + * Get the [user_id] column value. + * + * @return int + */ + public function getUserId() + { + + return $this->user_id; + } + + /** + * Get the [optionally formatted] [created_at] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + + if ($this->created_at === null || $this->created_at === '') { + return null; + } elseif (!is_int($this->created_at)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->created_at); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); + } + } else { + $ts = $this->created_at; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Set the value of [question_id] column. + * + * @param int $v new value + * @return void + */ + public function setQuestionId($v) + { + + if ($this->question_id !== $v) { + $this->question_id = $v; + $this->modifiedColumns[] = InterestPeer::QUESTION_ID; + } + + if ($this->aQuestion !== null && $this->aQuestion->getId() !== $v) { + $this->aQuestion = null; + } + + } // setQuestionId() + + /** + * Set the value of [user_id] column. + * + * @param int $v new value + * @return void + */ + public function setUserId($v) + { + + if ($this->user_id !== $v) { + $this->user_id = $v; + $this->modifiedColumns[] = InterestPeer::USER_ID; + } + + if ($this->aUser !== null && $this->aUser->getId() !== $v) { + $this->aUser = null; + } + + } // setUserId() + + /** + * Set the value of [created_at] column. + * + * @param int $v new value + * @return void + */ + public function setCreatedAt($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE + throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->created_at !== $ts) { + $this->created_at = $ts; + $this->modifiedColumns[] = InterestPeer::CREATED_AT; + } + + } // setCreatedAt() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->question_id = $rs->getInt($startcol + 0); + + $this->user_id = $rs->getInt($startcol + 1); + + $this->created_at = $rs->getTimestamp($startcol + 2, null); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 3; // 3 = InterestPeer::NUM_COLUMNS - InterestPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating Interest object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(InterestPeer::DATABASE_NAME); + } + + try { + $con->begin(); + InterestPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isNew()) + { + $this->setCreatedAt(time()); + } + + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(InterestPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // We call the save method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aQuestion !== null) { + if ($this->aQuestion->isModified()) { + $affectedRows += $this->aQuestion->save($con); + } + $this->setQuestion($this->aQuestion); + } + + if ($this->aUser !== null) { + if ($this->aUser->isModified()) { + $affectedRows += $this->aUser->save($con); + } + $this->setUser($this->aUser); + } + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = InterestPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += InterestPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * + * @return mixed true if all columns pass validation + * or an array of ValidationFailed objects for columns that fail. + * @see doValidate() + */ + public function validate($columns = null) + { + if ($columns) { + return InterestPeer::doValidate($this, $columns); + } + return $this->doValidate(); + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate() + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + // We call the validate method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aQuestion !== null) { + if (($retval = $this->aQuestion->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + + if ($this->aUser !== null) { + if (($retval = $this->aUser->validate()) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + } + + + if (($retval = InterestPeer::doValidate($this)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $names = InterestPeer::getFieldNames($type); + $pos = InterestPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getQuestionId(); + break; + case 1: + return $this->getUserId(); + break; + case 2: + return $this->getCreatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = InterestPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getQuestionId(), + $keys[1] => $this->getUserId(), + $keys[2] => $this->getCreatedAt(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $names = InterestPeer::getFieldNames($type); + $pos = array_search($name, $names); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setQuestionId($value); + break; + case 1: + $this->setUserId($value); + break; + case 2: + $this->setCreatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = InterestPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setQuestionId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(InterestPeer::DATABASE_NAME); + + if ($this->isColumnModified(InterestPeer::QUESTION_ID)) $criteria->add(InterestPeer::QUESTION_ID, $this->question_id); + if ($this->isColumnModified(InterestPeer::USER_ID)) $criteria->add(InterestPeer::USER_ID, $this->user_id); + if ($this->isColumnModified(InterestPeer::CREATED_AT)) $criteria->add(InterestPeer::CREATED_AT, $this->created_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(InterestPeer::DATABASE_NAME); + + $criteria->add(InterestPeer::QUESTION_ID, $this->question_id); + $criteria->add(InterestPeer::USER_ID, $this->user_id); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + + $pks[0] = $this->getQuestionId(); + + $pks[1] = $this->getUserId(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + + $this->setQuestionId($keys[0]); + + $this->setUserId($keys[1]); + + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of Interest (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setCreatedAt($this->created_at); + + + $copyObj->setNew(true); + + $copyObj->setQuestionId(NULL); // this is a pkey column, so set to default value + + $copyObj->setUserId(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return Interest Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return InterestPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new InterestPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a Question object. + * + * @param Question $v + * @return void + * @throws PropelException + */ + public function setQuestion($v) + { + + + if ($v === null) { + $this->setQuestionId(NULL); + } else { + $this->setQuestionId($v->getId()); + } + + + $this->aQuestion = $v; + } + + + /** + * Get the associated Question object + * + * @param Connection Optional Connection object. + * @return Question The associated Question object. + * @throws PropelException + */ + public function getQuestion($con = null) + { + // include the related Peer class + include_once 'model/om/BaseQuestionPeer.php'; + + if ($this->aQuestion === null && ($this->question_id !== null)) { + + $this->aQuestion = QuestionPeer::retrieveByPK($this->question_id, $con); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + $obj = QuestionPeer::retrieveByPK($this->question_id, $con); + $obj->addQuestions($this); + */ + } + return $this->aQuestion; + } + + /** + * Declares an association between this object and a User object. + * + * @param User $v + * @return void + * @throws PropelException + */ + public function setUser($v) + { + + + if ($v === null) { + $this->setUserId(NULL); + } else { + $this->setUserId($v->getId()); + } + + + $this->aUser = $v; + } + + + /** + * Get the associated User object + * + * @param Connection Optional Connection object. + * @return User The associated User object. + * @throws PropelException + */ + public function getUser($con = null) + { + // include the related Peer class + include_once 'model/om/BaseUserPeer.php'; + + if ($this->aUser === null && ($this->user_id !== null)) { + + $this->aUser = UserPeer::retrieveByPK($this->user_id, $con); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + $obj = UserPeer::retrieveByPK($this->user_id, $con); + $obj->addUsers($this); + */ + } + return $this->aUser; + } + +} // BaseInterest Index: /tags/release_day_7/lib/model/Question.php =================================================================== --- /tags/release_day_7/lib/model/Question.php (revision 18) +++ /tags/release_day_7/lib/model/Question.php (revision 18) @@ -0,0 +1,36 @@ +setStrippedTitle(myTools::stripText($v)); + } + + public function getAllInterestedUsers() + { + $c = new Criteria(); + $c->addJoin(UserPeer::ID, InterestPeer::USER_ID, Criteria::LEFT_JOIN); + $c->add(InterestPeer::QUESTION_ID, $this->getId()); + + return UserPeer::doSelect($c); + } +} + +?> Index: /tags/release_day_7/lib/model/map/QuestionMapBuilder.php =================================================================== --- /tags/release_day_7/lib/model/map/QuestionMapBuilder.php (revision 12) +++ /tags/release_day_7/lib/model/map/QuestionMapBuilder.php (revision 12) @@ -0,0 +1,85 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('symfony'); + + $tMap = $this->dbMap->addTable('ask_question'); + $tMap->setPhpName('Question'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addForeignKey('USER_ID', 'UserId', 'int', CreoleTypes::INTEGER, 'ask_user', 'ID', false, null); + + $tMap->addColumn('TITLE', 'Title', 'string', CreoleTypes::LONGVARCHAR, false); + + $tMap->addColumn('STRIPPED_TITLE', 'StrippedTitle', 'string', CreoleTypes::LONGVARCHAR, false); + + $tMap->addColumn('BODY', 'Body', 'string', CreoleTypes::LONGVARCHAR, false); + + $tMap->addColumn('INTERESTED_USERS', 'InterestedUsers', 'int', CreoleTypes::INTEGER, false); + + $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); + + $tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false); + + } // doBuild() + +} // QuestionMapBuilder Index: /tags/release_day_7/lib/model/map/RelevancyMapBuilder.php =================================================================== --- /tags/release_day_7/lib/model/map/RelevancyMapBuilder.php (revision 4) +++ /tags/release_day_7/lib/model/map/RelevancyMapBuilder.php (revision 4) @@ -0,0 +1,77 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('symfony'); + + $tMap = $this->dbMap->addTable('ask_relevancy'); + $tMap->setPhpName('Relevancy'); + + $tMap->setUseIdGenerator(false); + + $tMap->addForeignKey('ANSWER_ID', 'AnswerId', 'int', CreoleTypes::INTEGER, 'ask_answer', 'ID', false, null); + + $tMap->addForeignKey('USER_ID', 'UserId', 'int', CreoleTypes::INTEGER, 'ask_user', 'ID', false, null); + + $tMap->addColumn('SCORE', 'Score', 'int', CreoleTypes::INTEGER, false); + + $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); + + } // doBuild() + +} // RelevancyMapBuilder Index: /tags/release_day_7/lib/model/map/InterestMapBuilder.php =================================================================== --- /tags/release_day_7/lib/model/map/InterestMapBuilder.php (revision 4) +++ /tags/release_day_7/lib/model/map/InterestMapBuilder.php (revision 4) @@ -0,0 +1,75 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('symfony'); + + $tMap = $this->dbMap->addTable('ask_interest'); + $tMap->setPhpName('Interest'); + + $tMap->setUseIdGenerator(false); + + $tMap->addForeignPrimaryKey('QUESTION_ID', 'QuestionId', 'int' , CreoleTypes::INTEGER, 'ask_question', 'ID', true, null); + + $tMap->addForeignPrimaryKey('USER_ID', 'UserId', 'int' , CreoleTypes::INTEGER, 'ask_user', 'ID', true, null); + + $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); + + } // doBuild() + +} // InterestMapBuilder Index: /tags/release_day_7/lib/model/map/UserMapBuilder.php =================================================================== --- /tags/release_day_7/lib/model/map/UserMapBuilder.php (revision 16) +++ /tags/release_day_7/lib/model/map/UserMapBuilder.php (revision 16) @@ -0,0 +1,85 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('symfony'); + + $tMap = $this->dbMap->addTable('ask_user'); + $tMap->setPhpName('User'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addColumn('NICKNAME', 'Nickname', 'string', CreoleTypes::VARCHAR, false); + + $tMap->addColumn('FIRST_NAME', 'FirstName', 'string', CreoleTypes::VARCHAR, false); + + $tMap->addColumn('LAST_NAME', 'LastName', 'string', CreoleTypes::VARCHAR, false); + + $tMap->addColumn('EMAIL', 'Email', 'string', CreoleTypes::VARCHAR, false); + + $tMap->addColumn('SHA1_PASSWORD', 'Sha1Password', 'string', CreoleTypes::VARCHAR, false); + + $tMap->addColumn('SALT', 'Salt', 'string', CreoleTypes::VARCHAR, false); + + $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); + + } // doBuild() + +} // UserMapBuilder Index: /tags/release_day_7/lib/model/map/AnswerMapBuilder.php =================================================================== --- /tags/release_day_7/lib/model/map/AnswerMapBuilder.php (revision 12) +++ /tags/release_day_7/lib/model/map/AnswerMapBuilder.php (revision 12) @@ -0,0 +1,83 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('symfony'); + + $tMap = $this->dbMap->addTable('ask_answer'); + $tMap->setPhpName('Answer'); + + $tMap->setUseIdGenerator(true); + + $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addForeignKey('QUESTION_ID', 'QuestionId', 'int', CreoleTypes::INTEGER, 'ask_question', 'ID', false, null); + + $tMap->addForeignKey('USER_ID', 'UserId', 'int', CreoleTypes::INTEGER, 'ask_user', 'ID', false, null); + + $tMap->addColumn('BODY', 'Body', 'string', CreoleTypes::LONGVARCHAR, false); + + $tMap->addColumn('RELEVANCY_UP', 'RelevancyUp', 'int', CreoleTypes::INTEGER, false); + + $tMap->addColumn('RELEVANCY_DOWN', 'RelevancyDown', 'int', CreoleTypes::INTEGER, false); + + $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false); + + } // doBuild() + +} // AnswerMapBuilder Index: /tags/release_day_7/lib/model/Relevancy.php =================================================================== --- /tags/release_day_7/lib/model/Relevancy.php (revision 12) +++ /tags/release_day_7/lib/model/Relevancy.php (revision 12) @@ -0,0 +1,52 @@ +begin(); + + $ret = parent::save(); + + // update relevancy in answer table + $answer = $this->getAnswer(); + if ($this->getScore() == 1) + { + $answer->setRelevancyUp($answer->getRelevancyUp() + 1); + } + else + { + $answer->setRelevancyDown($answer->getRelevancyDown() + 1); + } + $answer->save(); + + $con->commit(); + + return $ret; + } + catch (Exception $e) + { + $con->rollback(); + throw $e; + } + } +} + +?> Index: /tags/release_day_7/lib/myTools.class.php =================================================================== --- /tags/release_day_7/lib/myTools.class.php (revision 12) +++ /tags/release_day_7/lib/myTools.class.php (revision 12) @@ -0,0 +1,23 @@ + Index: /tags/release_day_7/data/sql/sqldb.map =================================================================== --- /tags/release_day_7/data/sql/sqldb.map (revision 4) +++ /tags/release_day_7/data/sql/sqldb.map (revision 4) @@ -0,0 +1,2 @@ +# Sqlfile -> Database map +schema.sql=symfony Index: /tags/release_day_7/data/sql/schema.sql =================================================================== --- /tags/release_day_7/data/sql/schema.sql (revision 16) +++ /tags/release_day_7/data/sql/schema.sql (revision 16) @@ -0,0 +1,117 @@ +# This is a fix for InnoDB in MySQL >= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. + +SET FOREIGN_KEY_CHECKS = 0; +# ----------------------------------------------------------------------- +# ask_question +# ----------------------------------------------------------------------- +DROP TABLE IF EXISTS `ask_question`; + +CREATE TABLE `ask_question`( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER , + `title` TEXT , + `stripped_title` TEXT , + `body` TEXT , + `interested_users` INTEGER default 0 , + `created_at` DATETIME , + `updated_at` DATETIME , + PRIMARY KEY(`id`), + INDEX `ask_question_FI_1` (`user_id`), + CONSTRAINT `ask_question_FK_1` + FOREIGN KEY (`user_id`) + REFERENCES `ask_user` (`id`) +) +Type=InnoDB; +# ----------------------------------------------------------------------- +# ask_answer +# ----------------------------------------------------------------------- +DROP TABLE IF EXISTS `ask_answer`; + +CREATE TABLE `ask_answer`( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `question_id` INTEGER , + `user_id` INTEGER , + `body` TEXT , + `relevancy_up` INTEGER default 0 , + `relevancy_down` INTEGER default 0 , + `created_at` DATETIME , + PRIMARY KEY(`id`), + INDEX `ask_answer_FI_1` (`question_id`), + CONSTRAINT `ask_answer_FK_1` + FOREIGN KEY (`question_id`) + REFERENCES `ask_question` (`id`) +, + INDEX `ask_answer_FI_2` (`user_id`), + CONSTRAINT `ask_answer_FK_2` + FOREIGN KEY (`user_id`) + REFERENCES `ask_user` (`id`) +) +Type=InnoDB; +# ----------------------------------------------------------------------- +# ask_user +# ----------------------------------------------------------------------- +DROP TABLE IF EXISTS `ask_user`; + +CREATE TABLE `ask_user`( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `nickname` VARCHAR(50) , + `first_name` VARCHAR(100) , + `last_name` VARCHAR(100) , + `email` VARCHAR(100) , + `sha1_password` VARCHAR(40) , + `salt` VARCHAR(32) , + `created_at` DATETIME , + PRIMARY KEY(`id`)) +Type=InnoDB; +# ----------------------------------------------------------------------- +# ask_interest +# ----------------------------------------------------------------------- +DROP TABLE IF EXISTS `ask_interest`; + +CREATE TABLE `ask_interest`( + `question_id` INTEGER NOT NULL , + `user_id` INTEGER NOT NULL , + `created_at` DATETIME , + PRIMARY KEY(`question_id`,`user_id`), + CONSTRAINT `ask_interest_FK_1` + FOREIGN KEY (`question_id`) + REFERENCES `ask_question` (`id`) +, + INDEX `ask_interest_FI_2` (`user_id`), + CONSTRAINT `ask_interest_FK_2` + FOREIGN KEY (`user_id`) + REFERENCES `ask_user` (`id`) +) +Type=InnoDB; +# ----------------------------------------------------------------------- +# ask_relevancy +# ----------------------------------------------------------------------- +DROP TABLE IF EXISTS `ask_relevancy`; + +CREATE TABLE `ask_relevancy`( + `answer_id` INTEGER , + `user_id` INTEGER , + `score` INTEGER , + `created_at` DATETIME , + INDEX `ask_relevancy_FI_1` (`answer_id`), + CONSTRAINT `ask_relevancy_FK_1` + FOREIGN KEY (`answer_id`) + REFERENCES `ask_answer` (`id`) +, + INDEX `ask_relevancy_FI_2` (`user_id`), + CONSTRAINT `ask_relevancy_FK_2` + FOREIGN KEY (`user_id`) + REFERENCES `ask_user` (`id`) +) +Type=InnoDB; + + + + + +# This restores the fkey checks, after having unset them +# in database-start.tpl + +SET FOREIGN_KEY_CHECKS = 1; + Index: /tags/release_day_7/data/fixtures/test_data.yml =================================================================== --- /tags/release_day_7/data/fixtures/test_data.yml (revision 16) +++ /tags/release_day_7/data/fixtures/test_data.yml (revision 16) @@ -0,0 +1,92 @@ +User: + anonymous: + nickname: anonymous + first_name: Anonymous + last_name: Coward + + fabien: + nickname: fabpot + first_name: Fabien + last_name: Potencier + password: symfony + email: fp@example.com + + francois: + nickname: francois + first_name: François + last_name: Zaninotto + password: adventcal + email: fz@example.com + +Question: + q1: + title: What shall I do tonight with my girlfriend? + user_id: fabien + body: | + We shall meet in front of the __Dunkin'Doghnuts__ before dinner, + and I haven't the slightest idea of what I can do with her. + She's not interested in programming, space opera movies nor insects. + She's kinda cute, so I really need to find something + that will keep her to my side for another evening. + + q2: + title: What can I offer to my step mother? + user_id: anonymous + body: | + My stepmother has everything a stepmother is usually offered + (watch, vacuum cleaner, earrings, del.icio.us account). + Her birthday comes next week, I am broke, and I know that + if I don't offer her something sweet, my girlfriend + won't look at me in the eyes for another month. + + q3: + title: How can I generate traffic to my blog? + user_id: francois + body: | + I have a very swell blog that talks + about my class and mates and pets and favorite movies. + +Interest: + i1: { user_id: fabien, question_id: q1 } + i2: { user_id: francois, question_id: q1 } + i3: { user_id: francois, question_id: q2 } + i4: { user_id: fabien, question_id: q2 } + +Answer: + a1_q1: + question_id: q1 + user_id: francois + body: | + You can try to read her poetry. Chicks love that kind of things. + + a2_q1: + question_id: q1 + user_id: fabien + body: | + Don't bring her to a doghnuts shop. Ever. Girls don't like to be + seen eating with their fingers - although it's nice. + + a3_q2: + question_id: q2 + user_id: fabien + body: | + The answer is in the question: buy her a step, so she can + get some exercise and be grateful for the weight she will + lose. + + a4_q3: + question_id: q3 + user_id: fabien + body: | + Build it with symfony - and people will love it. + +Relevancy: + rel1: + answer_id: a1_q1 + user_id: fabien + score: 1 + + rel2: + answer_id: a1_q1 + user_id: francois + score: -1 Index: /tags/release_day_7/web/error.php =================================================================== --- /tags/release_day_7/web/error.php (revision 2) +++ /tags/release_day_7/web/error.php (revision 2) @@ -0,0 +1,1 @@ +Une erreur s'est produite. Index: /tags/release_day_7/web/frontend_dev.php =================================================================== --- /tags/release_day_7/web/frontend_dev.php (revision 2) +++ /tags/release_day_7/web/frontend_dev.php (revision 2) @@ -0,0 +1,12 @@ +getController()->dispatch(); + +?> Index: /tags/release_day_7/web/robots.txt =================================================================== --- /tags/release_day_7/web/robots.txt (revision 2) +++ /tags/release_day_7/web/robots.txt (revision 2) @@ -0,0 +1,2 @@ +User-agent: * +Disallow: Index: /tags/release_day_7/web/unavailable.html =================================================================== --- /tags/release_day_7/web/unavailable.html (revision 2) +++ /tags/release_day_7/web/unavailable.html (revision 2) @@ -0,0 +1,13 @@ + + + + + + + +

Application not available.

+ +

Please, refresh your browser in about 5 seconds.

+ + + Index: /tags/release_day_7/web/css/layout.css =================================================================== --- /tags/release_day_7/web/css/layout.css (revision 8) +++ /tags/release_day_7/web/css/layout.css (revision 8) @@ -0,0 +1,138 @@ +/*CSS code from www.fu2k.org - In search of the One True Layout*/ + +#content_main +{ + float: left; + width: 530px; + margin-right: 10px; +} +#content_bar +{ + float: left; + width: 240px; +} +/* Start Mac IE5 filter \*/ +#content_main, #content_bar + { + padding-bottom: 32767px !important; + margin-bottom: -32767px !important; + } +@media all and (min-width: 0px) { +#content_main, #content_bar + { + padding-bottom: 0 !important; + margin-bottom: 0 !important; + } +#content_main:before, #content_bar:before + { + content: '[DO NOT LEAVE IT IS NOT REAL]'; + display: block; + background: inherit; + padding-top: 32767px !important; + margin-bottom: -32767px !important; + height: 0; + } +} +/* End Mac IE5 filter */ +/* IE Win can be a bit out - you might need to adjust +bottom value by -1px or as required */ +.verticalalign + { + position: absolute; + bottom: 0; + } +#content_main .verticalalign + { + width: 540px; + } +#content_bar .verticalalign + { + width: 240px; + } +/* hack for Opera 7+ */ +@media all and (min-width: 0px){ +.verticalalign + { + width: 100% !important; + } +/* But Opera 9 does it right, so CSS3 hax to the max */ +div[id^="content"] #content_main .verticalalign + { + width: 540px !important; + } +div[id^="content"] #content_bar .verticalalign + { + width: 240px !important; + } +} +/* hack for IEs of all persuasions */ +* html .verticalalign + { + width: 100% !important; + } +.verticalalign p + { + position: absolute; + bottom: 0; + right: 0; + margin: 0; + padding: 0; + background: #996666; + } +#content + { + width: 780px; + position: relative; + margin-left: auto; + margin-right: auto; + text-align: left; + overflow: hidden; /* This hides the excess padding in non-IE browsers */ + } +/* we need this for IE 5.01 - otherwise the wrapper does not expand to the +necessary height (unless fixed, this problem becomes even more acute +weirdness as the method is enhanced */ +#content + { +/* Normally a Holly-style hack height: 1% would suffice but that causes +IE 5.01 to completely collapse the wrapper - instead we float it */ + float: left; +/* NB. possibly only IE 5.01 needs to get this float value - otherwise 5.5 sometimes +(I saw it happen many moons ago) makes the width of wrapper too small +the float: none with the comment is ignored by 5.01, +5.5 and above see it and carry on about their business +It's probably fine to just remove it, but it's left here +just in case that many moons ago problem rears its head again */ + float/**/: none; + } +/* easy clearing */ +#content:after + { + content: '[DO NOT LEAVE IT IS NOT REAL]'; + display: block; + height: 0; + clear: both; + visibility: hidden; + } +#content + { + display: inline-block; + } +/*\*/ +#content +{ + display: block; +} +/* end easy clearing */ +#header, #footer +{ + width: 780px; +} +/* Safari needs this - otherwise the ghost overflow, though painted +correctly obscures links and form elements that by rights should be above it. +An unintended side-effect is that it cause such elements to vanish in IE 5.01 +and 5.5, hence the child selector hack */ +* > #footer, * > form, * > #notes, * > .output +{ + position: relative; + z-index: 1000; +} Index: /tags/release_day_7/web/css/main.css =================================================================== --- /tags/release_day_7/web/css/main.css (revision 16) +++ /tags/release_day_7/web/css/main.css (revision 16) @@ -0,0 +1,148 @@ +ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input +{ margin: 0; padding: 0; } +a img,:link img,:visited img { border: none; } + +a:link, a:visited +{ + text-decoration: none; + color:#6E3291; +} + +a:hover +{ + text-decoration: underline; +} + +body, td +{ + margin: 0; + padding: 0; + font-family: Arial, sans-serif; + font-size: 12px; + background-color: #fff; +} + +body +{ + text-align: center; +} + +div#header +{ + margin-left: auto; + margin-right: auto; + text-align: left; + width: 780px; + height: 46px; +} + +div#header ul, div#footer ul +{ + list-style: none; + display:inline; + float:right; +} + +div#header li, div#footer li, div#header form +{ + display: inline; + list-style: none; +} + +div#header li +{ + padding: 0 7px; + font-weight: bold; + border-right: solid 1px #0066CC; +} + +div#header li.last +{ + border-right: none; +} + +div#header .last input +{ + border: solid 1px gray; + width:70px; + background-color: #F4F4F4; + vertical-align:sub; + margin-top:7px; +} + +div#header .last input:focus, div#header .last input:hover +{ + background-color: white; +} + +div#header li :link, div#header li :visited +{ + color:#0066CC; +} + +div#content_main +{ + background-color:white; +} + +div#content_main h1 +{ + padding: 5px; + font-size:14px; + margin-bottom:10px; + color: #B59D7A; + border-bottom: 1px solid #B59D7A; +} + +div#content_main h2 +{ + font-size:14px; +} + +div#content_main .interested_block +{ + float:left; + padding:4px 10px 10px 0; + width:60px; +} + +div#content_main .interested_mark +{ + font-size: 2em; + font-weight: bold; + width: 30px; + height: 30px; + background-color: #FFE56F; + border: 1px solid #ddd; + text-align: center; + margin-left:10px; +} + +div#content_main .question_body +{ + margin-top:6px; +} + +div#content_main hr +{ + background-color:white; + border:none; + border-top:solid 1px #B59D7A; + clear:both; + margin-bottom:10px; +} + +div#footer +{ + padding-top: 5px; + margin-left: auto; + margin-right: auto; + text-align: left; + width: 780px; + background-color: #bbb; +} + +.form_error +{ + color: #f00; +} Index: /tags/release_day_7/web/.htaccess =================================================================== --- /tags/release_day_7/web/.htaccess (revision 2) +++ /tags/release_day_7/web/.htaccess (revision 2) @@ -0,0 +1,19 @@ +Options +FollowSymLinks +ExecCGI + +RewriteEngine On + +# we skip all files with .something +RewriteCond %{REQUEST_URI} \..+$ +RewriteCond %{REQUEST_URI} !\.html$ +RewriteRule .* - [L] + +# we check if the .html version is here (caching) +RewriteRule ^$ index.html [QSA] +RewriteRule ^([^.]+)$ $1.html [QSA] +RewriteCond %{REQUEST_FILENAME} !-f + +# no, so we redirect to our front web controller +RewriteRule ^(.*)$ index.php [QSA,L] + +# big crash from our front web controller +ErrorDocument 500 "

Application error

SymFony application failed to start properly" Index: /tags/release_day_7/web/index.php =================================================================== --- /tags/release_day_7/web/index.php (revision 2) +++ /tags/release_day_7/web/index.php (revision 2) @@ -0,0 +1,12 @@ +getController()->dispatch(); + +?>