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

Model Can't be Loaded

I followed the models tutorial on the phalcon website and I keep get a Model\Expection error for a really simple query.


$app->get(
    "/api/meetings",
    function () use ($app) {
        $phql = "SELECT * FROM Store\\Meet\\Meetings ORDER BY meet_id";

        $meetings = $app->modelsManager->executeQuery($phql);

        $data = [];

        foreach($meetings as $meeting) {
            $data[] = [
                "meet_id" => $meeting->meet_id,
                "meet_topic" => $meeting->meet_topic,
                "meet_date" => $meeting->meet_date,
                "meet_time" => $meeting->meet_time,
                "meet_dur" => $meeting->meet_dur,
            ];
        }

        echo json_encode($data);
    }
);

Here is my Model:


namespace Store\Meet;

use Phalcon\Mvc\Model;

class Meetings extends Model 
{

    /*public function initialize()
    {
        $this->setSource("meetings");
    }*/

    public $meet_id;
    public $meet_topic;
    public $meet_date;
    public $meet_time;
    public $meet_dur;

    public function getMeetId($meet_id) {
        return $this->meet_id;
    }
    public function getMeetTopic($meet_topic) {
        return $this->meet_topic;
    }
    public function getMeetDate($meet_date) {
        return $this->meet_date;
    }
    public function getMeetTime($meet_time) {
        return $this->meet_time;
    }
    public function getMeetDur($meet_dur) {
        return $this->meet_dur;
    }
}

I've used this exact query in the robots tutorial app, do models require validations?

Also does Phalcon have any decent debuggers? Like laravel, because these errors message literally tell me nothing about what is going wrong.

Phalcon is compiled extension - so not, it doesn't have debugger because pretty much no way to do it.

You sure you loaded your models with loader?

Might need forward slash in the namespace

$phql = "SELECT * FROM \\Store\\Meet\\Meetings ORDER BY meet_id";

Make sure namespaces are being loaded properly with


$loader->registerNamespaces(

);

Forward slash not needed