Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Super Object in CodeIgniter?

I saw the term "Super Object" in CodeIgniter manual, but the term is not explained in details.

So, what is exactly "super object" in CodeIgnter?

like image 505
Morgan Cheng Avatar asked Apr 24 '10 03:04

Morgan Cheng


1 Answers

The codeigniter super object is the object that lets you refrence any loaded codeigniter resource or load new ones without initializing the classes each time.

for instance in your library if you wanted to refrence the database you would do the following

function whatever()
{
    $this->ci =& get_instance()  // sets an object in your library to point to the codeigniter object
    $this->ci->db->get('mytable');
}

where in a controller it would just be

function whatever
{
    $this->db->get('mytable);
}

this is because libraries do not have a refrence to the codeigniter object by default (for many reasons)

like image 96
Tom Schlick Avatar answered Oct 07 '22 00:10

Tom Schlick