-1
我正在嘗試爲內容模型控制器創建一個索引方法,並且出現以下錯誤,我在此處搜索但未找到相關答案。請看看下面的代碼和截圖:錯誤:1找不到。 - cakephp
Content.php:
class Content extends AppModel{
public $name = 'Content';
}
ContentsController.php:
class ContentsController extends AppController {
public $name = 'Contents';
public function index() {
$this->set('Contents', $this->Content->find('all'));
}
}
index.ctp:
<h1>View All Content</h1>
<table>
<tr>
<th>ID</th>
<th>Title</th>
<th>Content</th>
</tr>
<?php foreach ($Contents as $content) : ?>
<tr>
<td><?php echo $this->$content['Content']['id']; ?></td>
<td><?php echo $this->$content['Content']['title']; ?></td>
<td><?php echo $this->$content['Content']['content']; ?></td>
</tr>
<?php endforeach; ?>
</table>
截圖: http://postimg.org/image/sslcgoutx/
請幫忙,因爲我是cakephp的新手和學習它。
這個工作就像一個魅力:)謝謝! – Iglance3 2014-10-06 11:19:05
很高興這有助於你..請通過cakephp.org教程和文檔。 – justrohu 2014-10-06 11:55:03