Hi,
Since I have to work with dates a lot, I try to include the MySQL DQL
DATE_ADD function in Flextrine/Doctrine as showed on this page:
http://www.doctrine-project.org/blog/doctrine2-custom-dql-udfs
To start I created a DoctrineExtensions folder in the lib/ Directory
and placed the php classes within.
DateAdd.php snippet:
namespace DoctrineExtensions;
class DateAdd extends FunctionNode { ...
Then I added the function to the configuration in the
EntityManagerFactory:
// custom functions
$config->addCustomStringFunction('DATE_ADD', 'DoctrineExtensions/
DateAdd');
And finally registered the namespace in the bootstrap.php:
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Flextrine' => __DIR__."/../lib",
'Doctrine' => __DIR__.'/../lib',
'Symfony' => __DIR__.'/../lib/Doctrine',
'DoctrineExtensions' => __DIR__.'/../lib',
));
But I keep getting 'PHP Fatal error: require() [..]' errors:
Failed opening required '[...]flextrine/app/micemeta/entities/
DoctrineExtensions/DateAdd.php'
[...]
in [...] flextrine/lib/Doctrine/Common/ClassLoader.php
It seems, that the class is searched using the $entityClassLoader
instead of $loader. Is there a relatively simple way to get this to
work?
I must admit, that I'm not a PHP guru, and these two class loaders are
really confusing me.
Many thanks
- rico