开发者

What is Super Object in CodeIgniter?

开发者 https://www.devze.com 2022-12-27 19:52 出处:网络
I saw the term \"Super Object\" in 开发者_如何学编程CodeIgniter manual, but the term is not explained in details.

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?


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消