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

modelsManager error

this is my simple code

$app->get(
    '/users',
    function () use ($app) {
        $phql = "SELECT * FROM users";
        $users = $app->modelsManager->executeQuery($phql);
        $data = [];
        foreach ($users as $user) {
            $data[] = [
                'id'     => $user->id,
                'email'  => $user->email
            ];
        }
        echo json_encode($data);
    }
);

but it always goes 500 (internal server error) in my browser, if i just echoing something, it works well,

Use Fully Qualified Class Name for PHQL. For example:

$phql = "SELECT * FROM \My\Namespace\Users";


43.9k

Hi,

with error 500, you should have a look at your webserver logs, usually you will find tgere the reason of that error.