PHP Classes

How to make model

Recommend this page to a friend!

      MVC 4 Dummies  >  All threads  >  How to make model  >  (Un) Subscribe thread alerts  
Subject:How to make model
Summary:How to make model
Messages:2
Author:danidani
Date:2015-04-02 04:04:58
 

 


  1. How to make model   Reply   Report abuse  
Picture of danidani danidani - 2015-04-02 04:04:58
How to make model and display all database data in view

Thanks

  2. Re: How to make model   Reply   Report abuse  
Picture of Ali Sharifi Ali Sharifi - 2015-04-02 21:16:06 - In reply to message 1 from danidani
I dont make any BaseModel class that user could extend from the base model , but u can write ur model classes in the /model .
for example
<?php
Class User
{
public static function all(){
$users=DBHandler::getAll("SELECT password FROM users");
return $users;
}
}
and u can use this class methods in your controller to display the output in view like this
<?php
class HomeController extends BaseController
{
public function index(){
$users = User::all();
$this->templateEngine->assign('users',$users);
$this->templateEngine->display('home.tpl');
}
}