Zend 1.5 does not work

I have a service in zend and I want to use the registry to store sql queries all the time to get 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';
        }

He comes to a different state all the time. I do not know why?

+4
source share
1 answer

Basically, the \ Zend_Registry area is in the 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';
    }
+4
source

Source: https://habr.com/ru/post/1694778/


All Articles