dudapiotr / ZfTable

*Not supported*ZfTable 3.1. Awesome ZF2 table / grid (and much much more) generator with huge possibilities of decorating and conditioning. Integrated with DataTables, Doctrine 2, Bootstrap 2.0 and 3.0.
http://dudapiotrek.laohost.net/
MIT License
75 stars 59 forks source link

Table always list all results even with a where in source (Doctrine) #59

Closed Nyl000 closed 9 years ago

Nyl000 commented 9 years ago

Here is my code:

$id = (int) $this->params()->fromRoute('id', 0); $queryBuilder = $this->getEntityManager()->createQueryBuilder() ->add('select', 'q') ->add('from', $this->entityNamespace . ' q') ->leftJoin('q.customersInfos', 'b') ->leftJoin('b.customer', 'c') ->where('c.id = '.$id);

        $table = new ProductTable($this->getTranslator());
        $table
            ->setSource($queryBuilder)
            ->setParamAdapter($this->getRequest()->getPost());
        return $this->htmlResponse($table->render());

(a $query->getQuery()->getSQL() typed in phpmyadmin work as I want, but the table always show all my product table..)

Any ideas ??

olekhy commented 9 years ago

try andWhere

Nyl000 commented 9 years ago

olekhy: it doesn't work. Same request generated, same result :s

Nyl000 commented 9 years ago

Ok, solved this by passing the source in the table constructor..

//in controller:

$table = new ProductTable($this->getTranslator(), $queryBuilder);

//in table class:

function __construct(Translator $translator, $queryBuilder = null) { // .... $this->setSource($queryBuilder); // .... }

So the problem is when the setSource method si called I guess..