Welcome Guest, Not a member yet? Register   Sign In
declaring class level variables in codeigniter
#1

[eluser]Syed Wasti[/eluser]
Hi,

I am new to CI and what I want to do is to have a class level variable (which e.g is an array). But it seems like CI, despite all high bragging, doesn't support this feature. Nothing has been mentioned in the user guide about it. There is a heading called private functions and variables but the text has been seemingly kept silent regarding variables.

I want to have something like -->
Code:
class OrderStats extends CI_Controller {

protected $arr_CoreCountry = ('0'=>'uk', '1'=>'us');

public function __construct()
       {
      
            parent::__construct();
            // Your own constructor code
        
       }

       public function index()
    {
        
        $this->load->model('orders', '', TRUE);
        //$data['result'] = $this->Testmodel->get_entries();
        $data['result'] = $this->Testmodel->get_reports();
        $this->load->view('test', $data);
                        
    }
public function getOrderStats()
    {      
                $this->load->model('Orderstatsmodel', '', TRUE);
                
                //$data['result'] = $this->Testmodel->get_entries();
                foreach ($arr_CoreCountry as $key => $value)
                {
                    $data['result'] = $this->Orderstatsmodel->get_orderStats($key);
                }
//                $data['result'] = $this->Orderstatsmodel->get_orderStats(0);
                $this->load->view('orderstats', $data);
                        
    }

I keep getting an error messag that $arr_CoreCountry is an undefined variable. Where do I define it? Am I declaring it at a wrong place?

Expect a quick response as half of my day has been wasted just because of this s*** from codeigniter.


Messages In This Thread
declaring class level variables in codeigniter - by El Forum - 07-19-2011, 05:01 AM
declaring class level variables in codeigniter - by El Forum - 07-19-2011, 06:00 AM
declaring class level variables in codeigniter - by El Forum - 07-19-2011, 06:15 AM
declaring class level variables in codeigniter - by El Forum - 07-19-2011, 06:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB