effenti / propel-real-enum-behavior
1.1.0
2018-08-22 03:35 UTC
Requires
- propel/propel: ~2.0@dev
This package is not auto-updated.
Last update: 2022-11-22 20:32:08 UTC
README
要求
此行为是为 Propel 2 开发的。
它也仅在 MySQL 数据库上进行了测试,如果您希望对其进行测试或调整以适应其他数据库类型,请随时提出问题。
安装
composer require effenti/propel-real-enum-behavior
schema.xml
将行为添加到数据库的根目录或目标表。
以下是一个示例
<database ...> <!-- This will add the real-enum behavior for all enums in the database --> <behavior name="real-enum"/> <table name="my_table"> <column name="my_enum" type="ENUM" valueSet="FIRST,SECOND,THIRD" /> </table> </database>
使用方法
此行为执行了两个操作,使使用 ENUMS
更容易
- 现在您将在数据库中看到来自
valueSet
的 ENUM 值,而不是数字。 - 模型类现在将具有常量,以便轻松访问枚举值。使用上面的示例,我们可以这样从值集中获取值:
MyTable::MY_ENUM_SECOND