我是Codeigniter的新手,正试图从我的模型中调用一个函数,但我无法让它工作。有没有人能看到我做错了什么?
控制器(farm.php):
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Farm extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('harvest_first');
}
function harvest()
{
echo $this->harvest_first->harvest();
}
}型号(harvest_first.php):
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Harvest_first extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function harvest(){
return "THE FUNCTION";
}
}
?>我试图回显“函数”,但无论我做什么,我都不能让它像预期的那样工作。
谢谢,西蒙
发布于 2013-10-04 20:16:14
尝尝这个
class Harvest_first extends CI_Model更改为:
class Harvest_first_model extends CI_Model在控制器调用中,如下所示:
$this->load->model('harvest_first_model');和
$this->harvest_first_model->harvest();发布于 2013-10-04 20:38:22
Check here
https://stackoverflow.com/questions/19180853
复制相似问题