访问模型从codeigniter中的视图?

编程入门 行业动态 更新时间:2024-10-17 17:21:58
本文介绍了访问模型从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中的视图?

本文发布于:2023-11-17 12:33:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1610016.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   模型   codeigniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!