phpxajax

Accessing a Local Variable through Xajax and Classes in PHP


I have a Class

<?php
class cms{
    private $dataset;
    private $columns;
    private $configs;    

    public function __construct(){
        global $frw, $dbg;
        $this->configs =array();
    }

    public function __get($key){
        if(array_key_exists($key, $this->configs)==true){
            return $this->configs[$key];
        }else{
            throw new Exception('Unable to get value from configuration. '.$key);
        }
    }

    public function __set($key, $value){
        if(array_key_exists($key,$this->configs)){
            throw new Exception('Unable to set configuration. '.$key);
        }else{
            $this->configs[$key] = $value;
        }
    }

    public function exists($key){
        if(isset($this->configs[$key])){
            return true;
        }else{
            return false;
        }
    }


  public function load(){

  }

}
?>

$cms = new $cms;

I need to have a variable set on the page that instatiates the object and is available globally throughout each page (for duration of session). I do not want a session variable and I'd like not to use a global. Is there a way of passing the $dataset between pages and calling $cms->dataset in an xajax load. I keep thinking that I should be able to set a variable $dataset = $cms->__get('dataset');


Solution

  • Declare $dataset as public right now private $dataset is not accessible out side the class

    public $dataset;
    

    will be accessible outside the class

    $cms->dataset