/**
  * 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)
 {
     $pos = SchemaPropertyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
     return $this->setByPosition($pos, $value);
 }
 /**
  * overload schemaSave
  *
  * @return mixed
  *
  * @param  integer $userId
  *
  * @throws Exception
  * @throws PropelException
  */
 public function saveSchemaProperty($userId)
 {
     //if the property is modified then
     if ($this->isModified() || $this->isNew()) {
         $fields = Schema::getProfileArray();
         /** @var $field ProfileProperty */
         foreach ($fields as $field) {
             $fieldIds[sfInflector::underscore($field->getName())] = ["id" => $field->getId(), "hasLang" => $field->getHasLanguage()];
         }
         $statusId = $this->getStatusId();
         $con = Propel::getConnection(SchemaPropertyPeer::DATABASE_NAME);
         try {
             //start a transaction
             $con->begin();
             $this->setUpdatedUserId($userId);
             //if the property is new then
             if ($this->isNew()) {
                 //set the created user
                 $this->setCreatedUserId($userId);
             }
             //FIXME if the status is modified we have to update all of the existing statement statuses -- IF THEY MATCH THE OLD STATUS
             $columns = $this->modifiedColumns;
             //save it last
             $affectedRows = $this->save($con);
             $skipArray = ["is_subproperty_of", "is_subclass_of"];
             foreach ($columns as $column) {
                 $fieldName = SchemaPropertyPeer::translateFieldName($column, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME);
                 if (in_array($fieldName, $skipArray)) {
                     $object = $this->getParentUri();
                     if ("class" == $this->getType()) {
                         $fieldName = "is_subclass_of";
                         $objectId = $this->getIsSubclassOf();
                     } else {
                         $fieldName = "is_subproperty_of";
                         $objectId = $this->getIsSubpropertyOf();
                     }
                 } else {
                     $object = $this->getByName($column, BasePeer::TYPE_COLNAME);
                     $objectId = null;
                 }
                 SchemaPropertyPeer::updateRelatedElements($this, $fieldName, $object, $objectId, $userId, $fieldIds, $statusId, $con);
             }
             //commit the transaction
             $con->commit();
             return $affectedRows;
         } catch (PropelException $e) {
             $con->rollback();
             throw $e;
         }
     }
 }