What do you use instead of ENUM in Doctrine2? smallint? I thought of using varchar, or explicitly define char, but this may not be very effective when it comes to indexes, or am
You should use fre5h/DoctrineEnumBundle for doctrine when using symfony:
Example of using
Create a class for new ENUM type BasketballPositionType:
'Point Guard',
self::SHOOTING_GUARD => 'Shooting Guard',
self::SMALL_FORWARD => 'Small Forward',
self::POWER_FORWARD => 'Power Forward',
self::CENTER => 'Center'
];
}
Register BasketballPositionType for Doctrine in config.yml:
doctrine:
dbal:
types:
BasketballPositionType: App\DBAL\Types\BasketballPositionType
Create a Player entity that has a position field:
id;
}
public function setPosition(string $position)
{
$this->position = $position;
}
public function getPosition(): string
{
return $this->position;
}
}
Now you can set a position for Player inside some action or somewhere else:
$player->setPosition(BasketballPositionType::POINT_GUARD);