2012-01-28 35 views
1

我在CONTROLLER和ACTION中執行數據庫查詢,現在返回一個ARRAY(我想傳輸此數據)。現在我想通過URL將這些數據傳遞給前端FLASH(JSON格式)。像URL是/ controller/action/new/id/1 /,這是怎麼回事?我怎麼能創建網址來傳遞這個值?PHP ZEND使用Json值創建URL

回答

1

我不知道,如果你確實需要JSON你的目的,但如果你這樣做,你可以轉換一個數組JSON:

//should work for most objects as well 
$array = array(); 
$data = Zend_Json::encode($array); 
//make the json human readable if required 
$pretty = Zend_Json::prettyPrint($data,array($options = NULL))<br /> 

Zend_Json:: Ref
這最簡單的(但不是唯一方式)的方式要在ZF的URL發送的信息是使用_forward:
Zend_Controller_Action() Utility Methods

$this->_forward('action', 'controller', 'module', array('key' => 'value'); 

'控制器'的故障'模塊'爲空