I'm using tutorial-master https://docs.phalcon.io/en/latest/reference/tutorial.html the Create step from CRUD is awesome, I can input data to database. But I don't understand how to generating data from table using query.
this code didn't work because I use $application = new Application($di); not micro. <?php
// Retrieves all robots $app->get('/api/robots', function () use ($app) {
$phql = "SELECT * FROM Robots ORDER BY name";
$robots = $app->modelsManager->executeQuery($phql);
$data = array();
foreach ($robots as $robot) {
$data[] = array(
'id' => $robot->id,
'name' => $robot->name
);
}
echo json_encode($data);
});
I want to have $query="SELECT * FROM ospos ORDER BY ospoId"; and output $data = array(); echo jsone_encode($data) and resulting same result as micro code.. please help Thank you.