开发者

Doctrine enum type by value

开发者 https://www.devze.com 2023-01-01 13:13 出处:网络
I have a column in a table defined as following in my yaml file: myTable: columns: value: type: enum length: 2

I have a column in a table defined as following in my yaml file:

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开发者_StackOverflow中文版 this it works

I am using Doctrine 1.1.0.


Does $obj->setValue('yes') work? And the obvious thing to check are you calling save on the object?


You should not set length with enum type, as its internally treated as integer.

0

精彩评论

暂无评论...
验证码 换一张
取 消