1

I am new to CI and I want to update some data in mysql . So here is my controller

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);
    }
}

and my model is :

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);
    }
}

But when I tried to run the program , it says Call to undefined method Ci_update::ci_update_model() in C:\wamp\www\ci\application\controllers\ci_update.php on line 19 What wrom am I doing?

4

3 回答 3

6

Use as below

$this->load->model('ci_update_model');
$this->ci_update_model->updateData($data,$id);
于 2012-11-02T05:44:39.283 回答
0

DO this changes in your Controller code,Rest is same:

 $this->load->model('ci_update_model');
 $this->ci_update_model->updateData($data,$id);
于 2012-11-02T05:55:58.240 回答
-3

in your controller's constructer add this line

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

and the error will get resolved

于 2012-11-02T05:41:29.837 回答