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

Problem with model manager

Hi,

I have a problem with my modelsManager, when I try this code in my controller :

$phql = "select * from TABLE"; $action = $this->modelsManager->executeQuery($phql);

I get this error : "Using $this when not in object context".. It's like modelsManager is not recognised at all.

In my configuration, I have a Micro class that I instantiate in my index.php and that contains :

$di->set('modelsManager', function() { return new \Phalcon\Mvc\Model\Manager(); });

I also tried "$app->modelsManager", it is still the same error and var_dump($app) equals to NULL.

Any ideas ?

Thanks for your help.



58.4k

Hi

You can upload code on github. I will help make you problem that