We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Model::query Left join getting model not loaded error.

So here is my query.

use Nova\Models\Accounts;
use Nova\Models\AccountStatus;

public function indexAction(){
  $statusCount = AccountStatus::query()
  ->leftJoin('Accounts','a.id = AccountStatus.accountId','a')
  ->where('a.userId = :id:')
  ->bind(array('id' => 1)) // 1 is test value
  ->execute();
}

Getting this error:

Phalcon\Mvc\Model\Exception: Model 'Accounts' could not be loaded /nova/app/controllers/DashboardController.php (44)



34.6k
Accepted
answer

Model names inside strings aren't resolved by PHP: http://php.net/manual/en/language.namespaces.importing.php