I'm trying to make universal grid. I'm setting data to grid by giving the criteria instance, examples:
$criteria = Bendrijos::query(); if (!$this->user->admin) $criteria->innerJoin('Usertobendr', 'ub.bendr_id = Bendrijos.id', 'ub') ->andWhere('ub.user_id = :id:') ->bind(array('id' => $this->user->id)); $grid->setData($criteria);
$criteria = Users::query(); $grid->setData($criteria);
It is working at this moment, but I came to pagination task. I didn't checked before, so I have problem, because Phalcon\Paginator accepts only QueryBuilder instance.
- Is it possible somehow to workaround paginator to accept criteria as param?
- Actually querybuilder methods are similar to criteria, so I can use querybuilder instead of criteria, but how to get similar instance?:
Users::query() == $this->modelsManager->createBuilder()->from('Users')