Hi Johny,

Enum is mysql specific, so, you cannot have an enum in your schema.xml.

If you don't want to create another table to store the different 
possible values, you can simulate an enum very easily.

Imagine you have a status column in you article table you want to be an 
enum with values like ('open', 'closed'). Simply declare the status 
column as integer and then (not tested):

In your ArticlePeer.php class:

class ArticlePeer...
{
   static protected $STATUS_INTEGERS = array('open', 'closed');
   static protected $STATUS_VALUES = null;

   static public function getStatusFromIndex($index)
   {
     return self::$STATUS_INTEGERS[$index];
   }

   static public function getStatusFromValue($value)
   {
     if (!self::$STATUS_VALUES)
     {
       self::STATUS_VALUES = array_flip(self::$STATUS_INTEGERS);
     }

     $values = strtolower($value);

     if (!isset(self::STATUS_VALUES[$value])
     {
       throw new PropelException(sprintf('Status cannot take "%s" as a 
value', $value));
     }

     return self::STATUS_VALUES[strtolower($value)];
   }
}

In your Article.php class:

class Article
{
   public function setStatusName($value)
   {
     $this->setStatus(self::getStatusFromValue($value));
   }

   public function getStatusName()
   {
     return self::getStatusFromIndex($this->getStatus());
   }
}

Fabien


johnny wrote:
> Does anyone know how to declare Enum in the schema.xml?
> 
> 
> > 
> 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs
-~----------~----~----~----~------~----~------~--~---

Reply via email to