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 @@ + + +
asked by getUser() ?> getCreatedAt('U')) ?> ago
+ + askeet users are interested by this question +| + | |
|---|---|
| message: | + +|
| code: | ++ |
| class: | ++ |
| file: | ++ |
| line: | ++ |
| stack trace | |
| info | |
| symfony | +v. | +
| PHP | +v. | +
| for help resolving this issue, please visit www.symfony-project.com. | +|
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 @@
+
+
+
+
+
+
+
+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 "