我是CI的新手,我想更新mysql中的一些数据。因此,这里是我的控制器Codeigniter控制器模型调用失败
class Ci_update extends CI_Controller
{
function __construct() {
parent::__construct();
}
function index()
{
$data = array
(
'title' => 'Data Structure using C',
'text' => 'Data Structure Using C, for, IIIrd Sem VTU CSE students'
);
$id = 4 ;
$this->load->model('ci_update_model');
$this->ci_update_model($data,$id);
}
}
,我的模式是:
class Ci_update_model extends CI_Model
{
function __construct() {
parent::__construct();
}
function updateData($data,$id)
{
$this->db->where('id',$id);
$this->db->update('data',$data);
}
}
但是,当我试图运行程序,它说:Call to undefined method Ci_update::ci_update_model() in C:\wamp\www\ci\application\controllers\ci_update.php on line 19
什么wrom我在干嘛?
当哟你已经加载模型,你必须调用其中的函数$ this-> ci_update_model-> function($ var)...不只是$ this-> ci_update_model($ var)...在你的情况下,你正在寻找函数ci_update_model在控制器类内部.. – Svetoslav