We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Moving builder to Model

Hi All,

I'm using $this->modelsManager->createBuilder()->from ... in controller as it is described in doc, however i wanted to builder functionality directly in model method. Can this be done?

Cheers Zenek

edited Apr '14
$query = new Phalcon\Mvc\Model\Query\Builder();
$results = $query->from('Robots')
   ->join('RobotsParts')
   ->limit(20)
   ->orderBy('Robots.name')
   ->getQuery()
   ->execute();