dtuy84033
2012-03-06 04:35
浏览 23
已采纳

设置要在视图中使用的数组对象

In cakephp, I retrieve data from mysql and assign them to an array but i am unable to reuse each element of it in the view.

In the controller i call the model to query data from the database, which have the following format

Array ([0]=>Array([user]=>Array([something]=>somevalue [somethingelse]=>someotherValue))
   [1]=>Array([user]=>Array([something]=>somevalue [somethingelse]=>someotherValue))
    .......)

and I initilize my ready-to-pass-to-view array as follows, $result is the array obtained from database.

$i=0;
foreach($result as $row)
{
   $exportDt[$i]['something']=$row['user'][something];
   $exportDt[$i]['somethingelse']=$row['user'][somethingelse];
}

this->set($exportDt);

How can i reuse this exportDt array in the view ? I am thinking that setting is allowed for only one dim array only.

图片转代码服务由CSDN问答提供 功能建议

在cakephp中,我从mysql中检索数据并将它们分配给一个数组,但我无法重用它的每个元素 在视图中。

在控制器中,我调用模型来查询数据库中的数据,该数据具有以下格式

  Array([0] =  > Array([user] => Array([something] => somevalue [somethingelse] => someotherValue))
 [1] =>数组([user] =>数组([something] =  > somevalue [somethingelse] => someotherValue))
 .......)
   
 
 

我启动了我的准备传递给 -view数组如下,$ result是从数据库获得的数组。

  $ i = 0; 
foreach($ result as $ row)
 {
 $ exportDt  [$ i] ['something'] = $ row ['user'] [something]; 
 $ exportDt [$ i] ['somethingelse'] = $ row ['user'] [somethingelse]; 
} \  n 
this-> set($ exportDt); 
   
 
 

如何在视图中重用此exportDt数组? 我想只允许一个dim数组的设置。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题