effenti/propel-real-enum-behavior

此包已被废弃且不再维护。作者建议使用 kodalto/propel-real-enum-behavior 包。

Propel 2 行为,用于更接近枚举类型应有的方式管理 ENUM 类型

安装: 256

依赖者: 0

建议者: 0

安全: 0

星星: 1

关注者: 3

分支: 1

开放问题: 0

类型:propel-behavior

1.1.0 2018-08-22 03:35 UTC

This package is not auto-updated.

Last update: 2022-11-22 20:32:08 UTC


README

Latest Stable Version Total Downloads License

要求

此行为是为 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