How to render ZF2 view within JSON response?

OK, i think i finally understood what you’re doing. I’ve found a solution that i think matches your criteria. Though i am sure that there is room for improvement, as there’s some nasty handwork to be done… public function indexAction() { if (!$this->getRequest()->isXmlHttpRequest()) { return array(); } $htmlViewPart = new ViewModel(); $htmlViewPart->setTerminal(true) ->setTemplate(‘module/controller/action’) ->setVariables(array( ‘key’ … Read more

configure multiple databases in zf2

If you look at the Zend\Db\Adapter\AdapterServiceFactory, you’ll see that your adapter configuration points to only one key ‘db’. Which means that the Adapter that it builds will always use this (unique) configuration key. I recommend you to create your own factory that would look like this : namespace Your\Namespace; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\Db\Adapter\Adapter; … Read more

How to do left join in Doctrine?

If you have an association on a property pointing to the user (let’s say Credit\Entity\UserCreditHistory#user, picked from your example), then the syntax is quite simple: public function getHistory($users) { $qb = $this->entityManager->createQueryBuilder(); $qb ->select(‘a’, ‘u’) ->from(‘Credit\Entity\UserCreditHistory’, ‘a’) ->leftJoin(‘a.user’, ‘u’) ->where(‘u = :user’) ->setParameter(‘user’, $users) ->orderBy(‘a.created_at’, ‘DESC’); return $qb->getQuery()->getResult(); } Since you are applying a condition … Read more

Difference in accessing arrays in PHP 5.3 and 5.4 or some configuration mismatch?

Array dereferencing, which is what you are using, was introduced in PHP 5.4 and won’t work in PHP 5.3. So $dbSettings = $sm->get( ‘Config’ )[ ‘doctrine’ ][ ‘connection’ ][ ‘orm_default’ ][ ‘params’ ]; Would need to be: $dbSettings = $sm->get( ‘Config’ ); $params = $dbSettings[ ‘doctrine’ ][ ‘connection’ ][ ‘orm_default’ ][ ‘params’ ];