Exemplo n.º 1
0
 /**
  * Stores a property.
  *
  * @param string $name Property name
  * @param mixed $value Property value
  * @param PropelPDO $con Optional. The database connection to use.
  *     Default is NULL.
  * @return self Returns $this.
  */
 public function setProperty($name, $value, PropelPDO $con = null)
 {
     $property = PropertyQuery::create()->filterByAccount($this)->findOneByName($name, $con);
     if ($property === null) {
         throw new Exception('Could not find property "' . $name . '".');
     }
     /* @var PropertyValue $propertyValue */
     $propertyValue = PropertyValueQuery::create()->filterByDomainId(null)->filterByUserId(null)->findOneByPropertyId($property->getId(), $con);
     if ($propertyValue === null) {
         $propertyValue = new PropertyValue();
         $propertyValue->setProperty($property);
     }
     $propertyValue->set($value)->save($con);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Stores a property.
  *
  * @param string $name Property name
  * @param mixed $value Property value
  * @param PropelPDO $con Optional. The database connection to use.
  *     Default is NULL.
  * @return BaseObject Returns {@link $object}.
  */
 public static function setProperty(BaseObject $object, $name, $value, PropelPDO $con = null)
 {
     $property = PropertyQuery::create()->filterByAccount($object->getAccount($con))->findOneByName($name, $con);
     if ($property === null) {
         throw new Exception('Could not find property "' . $name . '".');
     }
     $class = get_class($object);
     /* @var PropertyValue $propertyValue */
     $propertyValue = PropertyValueQuery::create()->{'filterBy' . $class}($object)->findOneByPropertyId($property->getId(), $con);
     if ($propertyValue === null) {
         $propertyValue = new PropertyValue();
         $propertyValue->setProperty($property)->{'set' . $class}($object);
     }
     $propertyValue->set($value)->save($con);
     return $object;
 }