用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3851|回复: 5
收起左侧

[已解决] 求助!controller中无法调用model中的方法

[复制链接]
发表于 2011-1-18 11:38:54 | 显示全部楼层 |阅读模式
求助,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,就出现这种问题了
请问版本的差异在哪里?
发表于 2011-1-18 16:34:03 | 显示全部楼层
parent::__construct();
这句错了,应该是
parent::Controller();
 楼主| 发表于 2011-1-19 16:03:08 | 显示全部楼层
parent::__construct();
这句错了,应该是
parent::Controller();
Hex 发表于 2011-1-18 16:34



    I have changed it already, but it still doesn't work...
发表于 2011-1-19 16:42:57 | 显示全部楼层
没看到哪调这个方法:
gethosts
 楼主| 发表于 2011-1-19 16:51:42 | 显示全部楼层
没看到哪调这个方法:
gethosts
bluelomo 发表于 2011-1-19 16:42



    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 ~
发表于 2011-2-13 00:18:12 | 显示全部楼层
$this->bes_model->gethosts();


真是个奇怪的问题!

本版积分规则