0
我有一个模型从我的数据库中提取一个我希望能够在我的视图中显示的列表。将模型中的值传递给Kohana中的视图3
这个模型看起来是这样的:
Class Model_services extends Model
{
public function get_services_list() {
$result = DB::select('*')->from('services')
->execute()
->as_array();
return $result;
}
}
我的控制器看起来是这样的:
public function action_index()
{
$this->template->title = "services";
$this->template->header = View::factory('header');
$services = Model::factory('services');
$this->template->content = View::factory('services')
->bind('result',$result)
$this->template->footer = View::factory('footer');
}
如何呈现在视图从模型中的变量?
感谢Kowser快速回复,我使用的模板控制器,现在它给我这个错误“ErrorException [2]:htmlspecialchars()[function.htmlspecialchars]:无效的多字节序列在参数〜SYSPATH \ classes \ kohana \ debug.php [311]“我仍然不知道我做错了什么 – user731144
从我的经验,我可以理解的事情$ item包含了一些具有unicode数据的东西,从而使该unicode数据成为多字节序列。你可以尝试使用print_r($ item)而不是Debug :: vars();作为你的 – Kowser
,它只是空,它更好地调查你的模型。至少它不应该是空的,这是我的理解。 – Kowser