开发者

relation in between controller and view [duplicate]

开发者 https://www.devze.com 2023-03-07 21:21 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: render the values of controllers to view
This question already has answers here: Closed 11 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号