chengmo03013106 发表于 2011-1-18 11:38:54

求助!controller中无法调用model中的方法

求助,controller中无法调入model中的方法
controller中的饿代码如下:
class Bem extends Controller {



        function __construct() {

                parent::__construct();



                $this->load->helper(array('form', 'url'));

                $this->load->library('form_validation');

                $this->load->library('tank_auth');

                $this->load->model('bes');

                $this->lang->load('tank_auth');

        }
}

model中自己写了一个bes.php文件
代码如下:
class Bes extends Model {
        function Bes() {
                parent::Model();
        }
function gethosts() {
                $this->db->order_by('HOSTID', 'asc');
                return $this->db->get('TBLHOST');
        }
}
不知道为什么不能调用
之前的环境是 php5.1.6 + mysql5.0.xx + CI 1.7.2,一切正常
现在变成了php 5.3.2 + mysql 5.1.xx + CI 1.7.2,就出现这种问题了
请问版本的差异在哪里?

Hex 发表于 2011-1-18 16:34:03

parent::__construct();
这句错了,应该是
parent::Controller();

chengmo03013106 发表于 2011-1-19 16:03:08

parent::__construct();
这句错了,应该是
parent::Controller();
Hex 发表于 2011-1-18 16:34 http://codeigniter.org.cn/forums/images/common/back.gif


    I have changed it already, but it still doesn't work...

bluelomo 发表于 2011-1-19 16:42:57

没看到哪调这个方法:
gethosts

chengmo03013106 发表于 2011-1-19 16:51:42

没看到哪调这个方法:
gethosts
bluelomo 发表于 2011-1-19 16:42 http://codeigniter.org.cn/forums/images/common/back.gif


    yep, Because I didn't copy the whole code~
but the problem 's solved already~
There are servial differences between PHP 5.3 and before~
Some grammer is currect in PHP 5.2 and before, but in PHP 5.3
Thanks for the replying ~

snllll 发表于 2011-2-13 00:18:12

$this->bes_model->gethosts();


真是个奇怪的问题!
页: [1]
查看完整版本: 求助!controller中无法调用model中的方法