mongodbのreportscollectionの中にあるdataを引き出そうと頑張っているのですが、
controller内で
lang
1$this->set('res', $this->Report->find());
でなら
index.ctpで
lang
1 <?php 2 3 try { 4 foreach($res as $doc) { 5 $id = $doc["id"]; 6 $status = $doc["status"]; 7 $modified = $doc["modified"]->toDateTime()->format('Y-m-d H:i:s'); 8 $created = $doc["created"]->toDateTime()->format('Y-m-d H:i:s'); 9 10 echo "<tr id='$id'> 11 <td>$status</td> 12 <td><a href='../details/index?id=$id'>$id</a></td> 13 <td>$modified</td> 14 <td>$created</td> 15 </tr>\n"; 16 } 17 } catch(MongoCollectionException $e) { 18 die("コネクションを確立できません。"); 19 } 20 21 ?>
これで表示をちゃんとできるのですが、
controller内で
lang
1$this->set('res', $this->Report->find('all'));
だと一気に表示できなくなります。
ちなみに
controllerで
lang
1echo var_dump($this->Report->find('all'));
で、データをちゃんと取得できるのはわかっています。
この場合どう書けばよいのでしょうか。
ここ3日間悩んでいます。どうか教えてください。お願いいたします。
追記
$this->Report->find('all');とした場合、以下のようなエラーが表示されます。
![イメージ説明]WIDTH:449説明]WIDTH:449
解決
lang
1<?php 2 foreach($res as $doc) { 3 $id = $doc["Report"]["id"]; 4 $status = $doc["Report"]["status"]; 5 $modified = $doc["Report"]["modified"]->toDateTime()->format('Y-m-d H:i:s'); 6 $created = $doc["Report"]["created"]->toDateTime()->format('Y-m-d H:i:s'); 7 8 echo "<tr id='$id'> 9 <td>$status</td> 10 <td><a href='../details/index?id=$id'>$id</a></td> 11 <td>$modified</td> 12 <td>$created</td> 13 </tr>\n"; 14 }
これでいけましたー
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/06/22 02:29
2015/06/22 04:06
退会済みユーザー
2015/06/22 04:49
2015/06/22 04:51
退会済みユーザー
2015/06/22 05:24