简体   繁体   English

值类型的枚举类型

[英]Doctrine enum type by value

I have a column in a table defined as following in my yaml file: 我的yaml文件中的定义如下表中的一列:

myTable:
  columns:
    value:
      type: enum
      length: 2
      values: ['yes', 'no']

In the code I am trying to insert data into this table but I can't figure out a way to insert the data using the enum text value (ie. 'yes' or 'no'). 在代码中,我试图将数据插入到此表中,但无法找到使用枚举文本值(即“是”或“否”)插入数据的方法。

What I was trying was is something like this: 我正在尝试的是这样的事情:

$obj = new myTable(); // the model for this table
$obj->value = 'yes'; // if I use the numerical value for this it works

I am using Doctrine 1.1.0. 我正在使用Doctrine 1.1.0。

Does $obj->setValue('yes') work? $ obj-> setValue('yes')是否有效? And the obvious thing to check are you calling save on the object? 显然需要检查的是您是否在对象上调用save?

您不应使用枚举类型设置长度,因为它在内部被视为整数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM