/** * Translates a fieldname to another type * * @param string $name field name * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM * @param string $toType One of the class type constants * @return string translated name of the field. * @throws PropelException - if the specified name could not be found in the fieldname mappings. */ public static function translateFieldName($name, $fromType, $toType) { $toNames = RolPeer::getFieldNames($toType); $key = isset(RolPeer::$fieldKeys[$fromType][$name]) ? RolPeer::$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(RolPeer::$fieldKeys[$fromType], true)); } return $toNames[$key]; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = RolPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNombre($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setDescripcion($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setActivo($arr[$keys[3]]); } }