I have a class Blocka_Model (actually a MODEL in KOhana framework) with 2 functions input() and output().The function input is called from a function wriiten inside a controller called Home_Controller and it passes an argument to the function input. Now I want that argument passed to input() function to be accessible in the function output(). Both the functions input() and output() are inside Model class Blocka_Model. I want to get that argument $val from input() to output)
class Blocka_Model extends Block_Model {
protected $tablname = 'moves';
public 开发者_StackOverflow中文版function input($val) { ... }
public function output() { ... }
}
Since your title says you wish to use a session
:
class Blocka_Model extends Block_Model {
protected $session_unique_id;
public function __construct() {
$this->session_unique_id = uniqid();
}
/*
* Save $val in our current session
*/
public function input($val) {
$_SESSION[get_class($this).$this->session_unique_id] = $val;
}
/*
* Check for a value in our session
* - if it is set, return it
* - else return null
*/
public function output() {
return isset($_SESSION[get_class($this).$this->session_unique_id]) ?
$_SESSION[get_class($this).$this->session_unique_id] : null;
}
}
精彩评论