atxlin 发表于 2010-6-8 13:03:23

想问下ci里如何在视图里直接调用模型里的方法

在视图里直接   <?php $this->model->function();?>
这样貌似不行?

Hex 发表于 2010-6-8 13:28:39

不要这样用,视图里最好只用 helper

atxlin 发表于 2010-6-8 13:47:03

那我在model里写了一个类,在视图里如何直接调用?
不像在controller里调。。。。

haohailuo 发表于 2010-6-8 19:11:17

HMVC
http://codeigniter.org.cn/forums/viewthread.php?tid=1319&highlight=HMVC

乌有 发表于 2010-6-12 10:06:20

在调用该view的控制器里load了模型,就可以在view里用该模型的方法.

Prince 发表于 2014-1-9 17:30:31

本帖最后由 Prince 于 2014-1-10 10:24 编辑

先调用
<?php $this->load->Model('模型文件的名字')?>
再调用方法
<?php $this->模型文件的名字->模型里面的方法?>
页: [1]
查看完整版本: 想问下ci里如何在视图里直接调用模型里的方法