5
votes

I am using doctrine 2 within zend framework 2. To generate entities using database table, the console command used is:

php doctrine-module orm:convert-mapping --force --from-database annotation ./export

When i run above command, it throws an error:

Unknown database type enum requested

How to solve this issue?

1
From the docs: "(...) By default Doctrine does not map the MySQL enum type to a Doctrine type. (...)". Check the documentation, there are two solutions proposed. - lluisaznar
I followed this link for answer: stackoverflow.com/questions/15086148/… - Mayank Awasthi
Doctrine does not support MySQL ENUM by default as ENUM is specific to MySQL. - Broncha

1 Answers

12
votes

You can add:

'doctrine_type_mappings' => array(
    'enum' => 'string'
)

in your global configuration file located in /config/autoload/global.php.

Example code:

        return array(
            'doctrine' => array(
                'connection' => array(
                    'orm_default' => array(
                        'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
                        'params' => array(
                            'host'     => 'localhost',
                            'port'     => '3306',
                            'user'     => 'username',
                            'password' => 'password',
                            'dbname'   => 'DevBrew',

                        ),
                        // To automatically convert enum to string
                        'doctrine_type_mappings' => array(
                            'enum' => 'string'
                        ),
                    )
                )
            )
       );