tags:

views:

285

answers:

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 this it works

I am using Doctrine 1.1.0.

+1  A: 

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

johnwards
I am going to give you the accepted answer as this is was what I was looking for. But it turns out my problem was I had set the underlying fields length of the field to 2 and 'yes' has a length of 3.
MitMaro
Thank you squire, I probably would have noticed the length if I hadn't answered from my phone!
johnwards
A: 

You should not set lenght with enum type, as it's internally traeted as integer.

spider