0

I have a Message controller that use Message_model to use the database by active record.
Everything is OK.

Message_model code

function send_message($data) {
        $this->db->insert($this->table_name, $data);
        $num = $this->db->affected_rows();
        return $this->db->insert_id();
}

But in another controller(User controller) that use the Message_model.
It give me

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined property: Maxdoodle::$db</p>
<p>Filename: core/Model.php</p>
<p>Line Number: 51</p>

I've setup the default active record in database.php
Because I can use it in Message controller as mention before.

CodeIgniter version:2.1.1

Magic
  • 1,182
  • 2
  • 18
  • 28

1 Answers1

0

Your database library is not loaded try auto load :

 $autoload[‘libraries’] = array(‘database’);
Abdul Manan
  • 2,255
  • 3
  • 27
  • 51