访问模型从codeigniter中的视图? [英] access model from view in codeigniter?
本文介绍了访问模型从codeigniter中的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
在控制器上加载模型
p> $ this-> load-> model('yourmodel');
将此模型分配给这样的变量
$ data ['model_obj'] = $ this-> yourmodel;
并将此数据数组分配给视图模板
在视图模板上使用$ model_obj对象调用模型方法
$ model_obj-> some_method b
希望这有助于...
can anyone tell me how do i access model from view in codeigniter?
解决方案
Load a model on the controller
$this->load->model('yourmodel');
Assign this model to a var like this
$data['model_obj'] = $this->yourmodel;
and assign this data array to your view template
Use $model_obj object on the view template for calling model methods
$model_obj->some_method()
Hope this helps ...
这篇关于访问模型从codeigniter中的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文