I have service in zend and I want to use registry for save sql requests all the time for fetch data.
$r = \Zend_Registry::isRegistered('somedata');
if($r) {
$somedata = \Zend_Registry::get('somedata');
echo $r.'yes';
}else {
$results = $this->getCurlRequest('abc', 'abc', null);
\Zend_Registry::set('somedata',$results);
$somedata = $results;
echo $r.'no';
}
It is coming all the time in else condition. I do not know why ?
Basically \Zend_Registry scope is within current request so you need to use Zend_Session for it.
if (Zend_Session::namespaceIsset('globalvars')) {
$globalSess = Zend_Session::namespaceGet('globalvars');
} else {
$globalSess = new Zend_Session_Namespace('globalvars');
}
if (isset($globalSess->yourkey)) {
echo 'Yes its is already there';
} else {
echo 'No it was not but setting it now';
$globalSess->yourkey = 'Your Value';
}