mari roza
mari roza

Reputation: 37

Unknown database type enum requested,Doctrine

when i want to generate Entity from data base i have this Error:

Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it

how can i resolve this issue.

Thanks in advance

Upvotes: 2

Views: 2925

Answers (3)

D.Samchuk
D.Samchuk

Reputation: 1279

If you really want to work with enums and don't convert them to strings, you should implement your custom type (it's really not a big deal). See enter link description here

But also, you have to extend list of types on your platform. So, simplest way to do that - override useless method \Doctrine\DBAL\Types\Type::getMappedDatabaseTypes with your own so like that:

class EnumType extends Type
{
    const NAME = "enum";

    // ... (your implemented methods)

    public function getMappedDatabaseTypes(AbstractPlatform $platform)
    {
        return ['enum'];
    }
}

Have a fun :)

Upvotes: 0

Giovani
Giovani

Reputation: 2547

Add the following line to your bootstrap.php

$entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');

Upvotes: 2

marcosh
marcosh

Reputation: 9008

You could try to do something like this in the onBootstrap module of your Module.php, to tell Doctrine to treat your enum like a string

$em = $e->getApplication()->getServiceManager()->get('Doctrine\ORM\EntityManager');
$platform = $em->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');

Upvotes: 2

Related Questions