2

Well the question pretty much lies in the title. I've read the docs and what I can't find out is how to register the function to my ORM Configuration.

Any help here? Thanks!

Edit: Okay I've done it as Sam said, and made my own class and registered it like

            'numeric_functions' => array(
                'LOG10'  => 'Admin\Model\Log10',
            ),

However it can't find the class and gives the error

Class 'Admin\Model\Log10' not found in C:\webserver\apache\htdocs\test\vendor\doctrine\orm\lib\Doctrine\ORM\Query\Parser.php on line 3322

Any idea on why this happens?

3
  • I think all you need is documented here: doctrine-project.org/blog/doctrine2-custom-dql-udfs.html
    – edigu
    Oct 1, 2013 at 21:46
  • Yes that's the doc, I have it linked in the post as well, however I need to make it work in ZF2, and I can't find how to register the function in the config, as I'm saying in my post. Oct 1, 2013 at 22:02
  • I've seen the docs so many times, but still not enough I guess.. thanks! Oct 2, 2013 at 10:54

2 Answers 2

11

Actually the link that @foozy gave you is all that you'd need. You simply extend your doctrine configuration array:

return array(
    'doctrine' => array(
        'connection'    => array(
            'orm_default' => array(
                // Foo
            )
        ),
        'configuration' => array(
            'orm_default' => array(
                'numeric_functions' => array(
                    'MD5'  => 'DoctrineExtensions\Query\Mysql\Md5'
                ),
                'datetime_functions' => array(),
                'string_functions'   => array(),
                'metadata_cache'     => 'filesystem',
                'query_cache'        => 'filesystem',
                'result_cache'       => 'filesystem',
            )
        )
    )
);
4
  • Ty very much, if you can check my edit on the original post :) Oct 2, 2013 at 12:58
  • @Systemfreak Sounds like an autoloading issue. Can you access the class from any controller directly?
    – Sam
    Oct 2, 2013 at 13:02
  • Ugh, I had a typo in the class name as it seemed. Btw you seem to know some stuff on ZF2, would it be inconvenient to ask you if I have any other issue? :) Oct 2, 2013 at 13:13
  • @Systemfreak short answer: yes ;) Just post issues here on StackOverflow and you'll find the help you need. If i feel like helping, you'll get my reply anyways...
    – Sam
    Oct 2, 2013 at 14:51
0

The error is connected to DoctrineExtensions autoload. For me both solutions from How to implement beberlei doctrine extensions in zend framework 2 (manual injection of custom functions and applying via config) worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.