It's not neccessary to emulate ENUMs yourself, Doctrine will do that for you, or will use native ENUMs if you choose to and your RDBMS supports them.
>From the "symfony and Doctrine with sfDoctrinePlugin" book: "The Doctrine enum type can either be emulated or you can use the native enum type if your DBMS supports it. It is off by default so you will need to enable an attribute to use native enums." all: doctrine: class: sfDoctrineDatabase param: dsn: 'mysql:host=localhost;dbname=symfony12doctrine' username: user attributes: use_native_enum: true] You are setting the values correctly using strings (html, xml, text) as specified in your schema. I suggest that you retrieve the property after setting it, to see whether the value is being set correctly in the model object but not being stored correctly in the DB, or whether the settings of the property is failing altogether: $e = new EntryData; $e->type = 'html'; print_r($e->toArray()); On May 15, 8:45 pm, joshuacoady <j...@lovetoknow.com> wrote: > This is my schema: > > EntryData: > columns: > id: > type: integer > primary: true > autoincrement: true > notnull: true > type: > type: enum > values: [text, xml, html] > notnull: true > > What's a working example of code for how I can create an object of > type EntryData, set its type and save it? > > This throws a validation exception: > > $e = new EntryData(); > $e->type = 1; > $e->save(); > > All of the following end up inseting a 0 into the type column in the > DB: > > $e = new EntryData(); > $e->type = 'html'; > $e->save(); > > $e = new EntryData(); > $e->type = 'xml'; > $e->save(); > > $e = new EntryData(); > $e->type = 'text'; > $e->save(); > > Am I missing something? > > I found this in the docs that shows how to define an > enum:http://www.doctrine-project.org/documentation/manual/1_1/en/defining-... > > But I could not find any docs for how to use an enum. > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---