I use the following way to get Zend_registry value from one controller to another but didn't success.Should I need to initiate Zend_registry in bootstrap.php or other file that I can use it between two files or more.
我使用以下方法从一个控制器获取Zend_registry值但没有成功。我应该在bootstrap.php或其他文件中启动Zend_registry,我可以在两个或更多文件之间使用它。
$registry = Zend_Registry::getInstance();
$registry->set('variableName', 'value');
or
Zend_Registry::set('variableName', $value);
And this is how you get the value
$registry = Zend_Registry::getInstance();
$registry->get('variableName');
or
Zend_Registry::get('variableName');
To get more then one array
获得更多的数组
$value = array("name" =>'pankaj',"post" =>'sendeveloper');
Zend_Registry::get('session')->variableName = $value;
$value1 = array("name" =>'rahul',"post" =>'jndeveloper');
Zend_Registry::get('session')->variableTable = $value;
$value3 = array("name" =>'vonod',"post" =>'techdeveloper');
Zend_Registry::get('session')->variabletech = $value;
It seems to work only variableName not other. What i need to do ?
它似乎只工作variableName而不是其他。我需要做什么 ?
1 个解决方案
#1
To solve this problem, I use Zend_Registry
and Zend_Session_Namespace
.
为了解决这个问题,我使用了Zend_Registry和Zend_Session_Namespace。
In the bootstrap:
在引导程序中:
protected function _initSession()
{
Zend_Registry::set('session', new Zend_Session_Namespace("doydoy44"));
}
And in UserController
:
在UserController中:
$value = array("name" =>'pankaj',"post" =>'developer');
Zend_Registry::get('session')->variableName = $value;
and in CustomerController
:
在CustomerController中:
var_dump(Zend_Registry::get('session')->variableName);
#1
To solve this problem, I use Zend_Registry
and Zend_Session_Namespace
.
为了解决这个问题,我使用了Zend_Registry和Zend_Session_Namespace。
In the bootstrap:
在引导程序中:
protected function _initSession()
{
Zend_Registry::set('session', new Zend_Session_Namespace("doydoy44"));
}
And in UserController
:
在UserController中:
$value = array("name" =>'pankaj',"post" =>'developer');
Zend_Registry::get('session')->variableName = $value;
and in CustomerController
:
在CustomerController中:
var_dump(Zend_Registry::get('session')->variableName);