i dont know how to integrate the beberlei doctrine-extensions: https://github.com/beberlei/DoctrineExtensions in Zend Framework 2 with Doctrine Module. I installed it with composer:
"beberlei/DoctrineExtensions": "dev-master"
I tried in my module.config.php from th application module:
'doctrine' => array(
'driver' => array(
__NAMESPACE__ .'_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/'.__NAMESPACE__.'/Entity')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__.'\Entity' => __NAMESPACE__. '_driver'
)
)
),
'configuration' => array(
'orm_default' => array(
'string_functions' => array(
'GroupConcat' => '/vendor/beberlei/DoctrineExtensions\Query\MsySql\GroupConcat'
)
)
)
),
but this Exception was thrown:
Fatal error: Class '/vendor/beberlei/DoctrineExtensions\Query\MsySql\GroupConcat' not found
The configuration doesn't need to reference the /vendor/beberlei
folder as this is handled by the autoloader.
The configuration should probably look something like this :
'doctrine' => array(
'driver' => array(
__NAMESPACE__ .'_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/'.__NAMESPACE__.'/Entity')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__.'\Entity' => __NAMESPACE__. '_driver'
)
)
),
'configuration' => array(
'orm_default' => array(
'string_functions' => array(
'GroupConcat' => 'DoctrineExtensions\Query\Mysql\GroupConcat'
)
)
)
),
After installing with Composer
"beberlei/DoctrineExtensions": "dev-master"
use this code in your service class:
$config = $this->getEntityManager()->getConfiguration();
$config->addCustomStringFunction('GROUP_CONCAT', 'DoctrineExtensions\Query\MySq\GroupConcat');
now you can use 'GROUP_CONCAT' in your DQL like this:
$dql = "SELECT GROUP_CONCAT(elem.name) FROM ..... GROUP BY ...";
$query = $this->getEntityManager()->createQuery($dql);
return $query->getArrayResult();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With