How to echo data from database in phalcon index.phtml file

How to echo data from database in phalcon index.phtml file. Just like the way we do foreach in codeigniter i want to render data in tabular form from my database in phalcom index.phtml . I am beginner with phalcon so please bare with me.



30.7k

Hi,

// in controller 

// fetch some data
$users = User::find();

// pass the data to the view 
$this->view->users = $users;

//in you view file:
    foreach ($users as $user) {
        echo "<tr>";
        echo "<td>" . $user->name . "</td><td>" . $user->birthdate . "</td>";
        echo "</tr>;
    }