Getting ENUM DataType to work with Doctrine 2 in Zend Framework 2

January 24th, 2013 by wickeddoc

When using Doctrine 2 with a MySQL Database which has tables with ENUM datatypes, you might run into the following error message:

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

This is because Doctrine 2 doesn’t support the ENUM DataType natively as you can read here: Doctrine Cookbook.

In their Doctrine Cookbook they give a solution how you can resolve this by mapping the ENUM to a STRING datatype. But if you’re using Zend Framework 2 you’ll probably run into the same question as I have: where do I put this stuff for it to work?

This might not be the perfect solution, but it worked for me.

Adding the required code to the onBootstrap() method of the Module.php file of the “default” module did the job.

class Module
{
    public function onBootstrap(MvcEvent $e)
    {
        ...
        $em = $e->getApplication()->getServiceManager()->get('Doctrine\ORM\EntityManager');
        $platform = $em->getConnection()->getDatabasePlatform();
        $platform->registerDoctrineTypeMapping('enum', 'string');
        ...
       
    }

}

Posted in Doctrine, PHP, Zend Framework | 4 Comments »

Mayflower Zend Framework Cheatsheet

December 31st, 2009 by wickeddoc

Several weeks ago I was scouting the Internet for a Zend Framework cheatsheet and I found a blog entry somewhere about a Zend Framework Cheatsheet Poster, created by a German company called Mayflower.

On their blog they say, if you’re an eager Zend Framework developer and want to get your copy of their Cheatsheet poster, you’ll just have to send them an email and you’ll get this great Poster delivered to your office or home or whatever, free of charge. So that’s what I did and guess what, a week later I received this very useful poster in the mail.
So if you are a Zend Framework developer yourself and want to own this cool poster, don’t be shy, just send an email to Bj√∂rn Schotte over at Mayflower.

Here’s a photo of the poster in our office @ Visual Online, Luxembourg

Mayflower Zend Framework Cheatsheet Poster

Posted in Zend Framework | No Comments »

Zend Studio forgetting about your ZF Project

June 16th, 2009 by wickeddoc

as a php developer i’m using zend studio for eclipse on a daily basis. sometimes zend studio forgets about my zend framework projects, especially projects which are hosted on a SVN repository. i close my project, reopen it, and for no obvious reasons zend studio no longer recognizes it as a zend framework project. huch!?

until now i was unable to find a real solution to my problem, but here’s a little workaround which should get you up and running again, in case you’re running into the same problem.

close the project, then just open the .project file at the root of your project in your favourite text editor and check the ‘natures’ section, make sure it contains the following line:

<nature>org.zend.php.framework.ZendFrameworkNature</nature>

that should do the trick.

Posted in PHP, Zend Framework | 2 Comments »

OverkillFlickr: a Flickr API interface for PHP5

July 9th, 2007 by wickeddoc

I create a small Flickr API interface for PHP5 which takes advantage of the Overloading feature of PHP5.

Using the __call method we can dynamically create an interface to all the Flickr API functions using only a very small script.

The name of the class is purely ironic as it is a very simple and easy-to-use class and far from Overkill.

Read the rest of this entry »

Posted in PHP | 7 Comments »

Pages

Recent Posts

Categories

Links


Archives

Meta