Welcome Guest, Not a member yet? Register   Sign In
Can I add $data in constructor?
#1

[eluser]shinokada[/eluser]
I have the following $data in all the functions.

I tried to add the following in constructor, in order to avoid repeating. But it does not work.

Can I add $data in the constructor?

I am repeating this.

Code:
$mostsold = $this->MProducts ->getMostSoldProducts();
    $data['mostsold']= $mostsold;
    
    $newproduct = $this->MProducts ->getNewProducts();
    $data['newproduct']= $newproduct;


I tried this, but it does not work.

Code:
function  __construct(){
    parent::Controller();
    session_start();
    // $this->output->cache(5);
    $this->output->enable_profiler(TRUE);
    $mostsold = $this->MProducts ->getMostSoldProducts();
    $data['mostsold']= $mostsold;
    
    $newproduct = $this->MProducts ->getNewProducts();
    $data['newproduct']= $newproduct;
    
  }


Messages In This Thread
Can I add $data in constructor? - by El Forum - 12-31-2009, 03:58 PM
Can I add $data in constructor? - by El Forum - 12-31-2009, 04:01 PM
Can I add $data in constructor? - by El Forum - 01-01-2010, 02:02 PM
Can I add $data in constructor? - by El Forum - 01-02-2010, 03:06 AM
Can I add $data in constructor? - by El Forum - 01-02-2010, 09:03 AM
Can I add $data in constructor? - by El Forum - 01-10-2010, 11:18 AM
Can I add $data in constructor? - by El Forum - 01-16-2010, 06:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB