• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why $CI =& get_instance(); in each function

#1
[eluser]TerryT[/eluser]
I have a library where I call this in the constructor:


Code:
class Mypdf extends TCPDF
function __construct()    {
  parent::__construct();  
    $CI =& get_instance();
    $CI->load->library('session');
    $CI->load->library('pdf');

I also have these methods:

Code:
public function newpdf($title, $subject, $report_name)
public function body_project_listing()

To access sessions in either of the functions, I have to call:

Code:
$CI =& get_instance();
    $CI->load->library('session');
    $CI->load->library('pdf');
[/code]

in each function. Can anyone let me know why I can't just call it in the parent::__construct()? Thanks.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.