relation in between controller and view [duplicate]
Possible Duplicate:
render the values of controllers to view
I 开发者_JAVA百科am newbie to php and I am doing a project in php object and class.Here I am fetching all the data in controller in array format.now my problem is how to display all the result in view file.What will be the relation in between them.I am not using anyframework.in my controller I have made query like this
<?php
class UserController {
public $db;
public function __construct($db) {
$this->db = $db;
}
public function index() {
$this->view->data = $this->db->query("SELECT * FROM users"));
}
}
?>
so how to do that?
Don't use public fields, use getters and setters (accessors).
In index method you can call something like $this->view->render();
Your code not perfect, so it can be useful to read: http://www.yiiframework.com/doc/guide/1.1/en/basics.mvc
精彩评论