public function executePersonalNotepad(sfWebRequest $request) { $note = PersonalNotePeer::retrieveByPK($this->getUser()->getId()); if (!$note instanceof PersonalNote) { $note = new PersonalNote(); $note->setPersonId($this->getUser()->getId()); $note->save(); } $this->note = $note; $this->allowed_tags = $this->getAllowedTags(); }
/** * Gets a single PersonalNote object, which is related to this object by a one-to-one relationship. * * @param PropelPDO $con * @return PersonalNote * @throws PropelException */ public function getPersonalNote(PropelPDO $con = null) { if ($this->singlePersonalNote === null && !$this->isNew()) { $this->singlePersonalNote = PersonalNotePeer::retrieveByPK($this->id, $con); } return $this->singlePersonalNote; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = PersonalNotePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setPersonId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNote($arr[$keys[1]]); } }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(PersonalNotePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(PersonalNotePeer::DATABASE_NAME); $criteria->add(PersonalNotePeer::PERSON_ID, $pks, Criteria::IN); $objs = PersonalNotePeer::doSelect($criteria, $con); } return $objs; }
public function executeSavePersonalNote(sfWebRequest $request) { $note = $request->getParameter('note'); $personal_note = PersonalNotePeer::retrieveByPK($this->getUser()->getId()); if (!$personal_note instanceof PersonalNote) { $personal_note = new PersonalNote(); $personal_note->setPersonId($this->getUser()->getId()); } $personal_note->setNote(strip_tags($note, sfConfig::get('app_allowed_note_tags'))); $personal_note->save(); return sfView::NONE; }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = PersonPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related EmailTemplate objects $c = new Criteria(EmailTemplatePeer::DATABASE_NAME); $c->add(EmailTemplatePeer::PERSON_ID, $obj->getId()); $affectedRows += EmailTemplatePeer::doDelete($c, $con); // delete related PasswordRequest objects $c = new Criteria(PasswordRequestPeer::DATABASE_NAME); $c->add(PasswordRequestPeer::PERSON_ID, $obj->getId()); $affectedRows += PasswordRequestPeer::doDelete($c, $con); // delete related PersonRole objects $c = new Criteria(PersonRolePeer::DATABASE_NAME); $c->add(PersonRolePeer::PERSON_ID, $obj->getId()); $affectedRows += PersonRolePeer::doDelete($c, $con); // delete related PersonalNote objects $c = new Criteria(PersonalNotePeer::DATABASE_NAME); $c->add(PersonalNotePeer::PERSON_ID, $obj->getId()); $affectedRows += PersonalNotePeer::doDelete($c, $con); } return $affectedRows; }