Trying to get property of non-object -- zf2 -- doctrine -- paginator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to get property of non-object -- zf2 -- doctrine -- paginator

dinispt
THIS IS THE ERROR

( ! ) Notice: Trying to get property of non-object in C:\websites\dinispt\module\Blog\view\blog\blogad\search.phtml on line 10
Call Stack
# Time Memory Function Location
1 0.0004 244808 {main}( ) ..\index.php:0
2 0.1436 8385976 Zend\Mvc\Application->run( ) ..\index.php:29
3 0.2691 17918048 Zend\Mvc\Application->completeRequest( ) ..\Application.php:330
4 0.2691 17918128 Zend\EventManager\EventManager->trigger( ) ..\Application.php:355
5 0.2691 17918336 Zend\EventManager\EventManager->triggerListeners( ) ..\EventManager.php:207
6 0.2697 17926440 call_user_func:{C:\websites\dinispt\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:468} ( ) ..\EventManager.php:468
7 0.2697 17926784 Zend\Mvc\View\Http\DefaultRenderingStrategy->render( ) ..\EventManager.php:468
8 0.2697 17927128 Zend\View\View->render( ) ..\DefaultRenderingStrategy.php:102
9 0.2708 17933552 Zend\View\View->renderChildren( ) ..\View.php:198
10 0.2708 17934496 Zend\View\View->render( ) ..\View.php:233
11 0.2718 17940336 Zend\View\Renderer\PhpRenderer->render( ) ..\View.php:205
12 0.2727 17963384 include( 'C:\websites\dinispt\module\Blog\view\blog\blogad\search.phtml' ) ..\PhpRenderer.php:506
i have this on my view

// THE ERROR ITS IN THIS LINE    
<?php echo $blogad->titulo;?> ON THE VIEW below , WITH DEBUG IT ENTERS HERE AND THE $blogad->titulo AS A VALUE STRING, BUT IT TROWS AN ERROR I DONT UNDERSTAND WHY
   
i removed the html
<?php foreach($paginator as $blogad) : ?>

<?php echo $blogad->titulo;?>
   
 

<?php endforeach; ?>



<?php echo $this->paginationControl($this->paginator,
                                    'Sliding', // All, Elastic, Jumping, Sliding
                                    'search_pagination.phtml', array('route' => 'bloghome/paginator-doctrine')); ?>




this its the code in my controller

public function searchAction()
    {
       
        $this->traduz();
               
        $entityManager = $this->getEntityManager();

        // Create a Doctrine Collection
        $query = $entityManager->createQuery('SELECT b FROM Blog\Entity\Blogad b')->setHydrationMode(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);
       
       
        //$query = $qb->getQuery();
        //$data = $query->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);

        // Create the paginator itself
        $paginator = new Paginator(
            new DoctrinePaginator(new ORMPaginator($query))
        );

        $paginator->setCurrentPageNumber(0)->setItemCountPerPage(10);
       
        return new ViewModel(array('paginator' => $paginator));


}

Reply | Threaded
Open this post in threaded view
|

Re: Trying to get property of non-object -- zf2 -- doctrine -- paginator

dinispt

its comming has an array not as a object

now its working

<?php echo $blogad['titulo'];?>