Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctrine Paginator foreach not working #70

Closed
reyezJelle opened this issue Oct 15, 2015 · 5 comments
Closed

Doctrine Paginator foreach not working #70

reyezJelle opened this issue Oct 15, 2015 · 5 comments

Comments

@reyezJelle
Copy link

After the latest changes the following example code stopped working:

<?php namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Doctrine\ORM\Tools\Pagination\Paginator;
use Doctrine\ORM\EntityManager;
use App\Repositories\Entities\Product;

class TestController extends BaseController
{

    private $product;

    public function __construct(EntityManager $em, Product $product)
    {
        $this->product = $product;
        $this->em = $em;
    }

    public function index()
    {
        $dql = "SELECT p FROM App\\Repositories\\Entities\\Product p ";
        $query = $this->em->createQuery($dql)
                          ->setFirstResult(0)
                          ->setMaxResults(100);
        $paginator = new Paginator($query, $fetchJoinCollection = true);
        $c = count($paginator);

        foreach( $paginator as $post )
        {
            dd($post, 2);
        }
    }

}
@patrickbrouwers
Copy link
Contributor

It would be useful if you could supply the exception.

Are you using a tagged release?

@reyezJelle
Copy link
Author

There is no exception, the foreach is just not looping. I've pulled a previous version and there this code was working and showed the result of dd($post,2);

I'm using "laravel-doctrine/orm": "dev-master",

@patrickbrouwers
Copy link
Contributor

Never use dev-master. It contains potential breaking changes or incomplete features.

Btw did you see in the documentation we have cleaner syntax for pagination?

@reyezJelle
Copy link
Author

Thank you, I have seen the code. The code was rushed a bit.

I've reverted to 1.0.5 for now.

@patrickbrouwers
Copy link
Contributor

1.0.5 is the latest stable release, so that's fine.
Thanks for using the package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants