Is there any reason not to save the key in the db instead of the value?
If I want to create an enumeration to populate a drop-down menu on a web page, I would like to be able to represent the options visible to the user as strings, even long ones, with spaces and other characters (which cannot be used as names of constants in PHP ), but save a shorter representation in the db.
For example:
class Reply extends Enum
{
public const YES = "Yes, I'm ready to accept";
public const NO = "No, I am not still ready";
}
Is there any reason not to save the key in the db instead of the value?
If I want to create an enumeration to populate a drop-down menu on a web page, I would like to be able to represent the options visible to the user as strings, even long ones, with spaces and other characters (which cannot be used as names of constants in PHP ), but save a shorter representation in the db.
For example: