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

Query Error

So i have an Multi apllication phalcon project and i'mtrying to execute this code on my controller :


use \Manager\Models\Team as Team,
    \Manager\Models\Users as Users,
    \Manager\Models\Departments as Departments;

  $params = [
       'models'     => ['Users'],
       'columns'    => ['email','permission','name','image','department'],
    ];
    $builder = new \Phalcon\Mvc\Model\Query\Builder($params);
    $builder->innerJoin('Team', 'Team.uid = Users._');
    $builder->innerJoin('Departments', 'Team.department_id = Departments._');
    $v = $this->modelsManager->createQuery($builder->getPhql())->execute();

    var_dump($v);

    $this->view->disable();

But i get the following error : Model 'Users' could not be loaded

how can i fix this ?



9.3k
Accepted
answer

In query builder you have to use model names with namespaces!

Instead of User write Manager\Models\Users Instead of Team write Manager\Models\Team Instead of Departments write Manager\Models\Departments