2007-9-19 17:35
Dereky
和 Zend Framework 一起成长的例子 出错,求教!
class IndexController extends Zend_Controller_Action
{
function init()
{
$this->initView();
$this->view->baseUrl = $this->_request->getBaseUrl();
Zend_Loader::loadClass('Album');
}
function indexAction()
{
$this->view->title = "My Albums";
$album =new Album();
$this->albums = $album->fetchAll();
print_r($this->albums);
exit;
$this->render();
}
}
这里打印出来的 $this->albums
是这样的:
Zend_Db_Table_Rowset Object
(
[_data:protected] => Array
(
[0] => Array
(
[id] => 1
[artist] => James Morrison
[title] => Undiscovered
)
[1] => Array
(
[id] => 2
[artist] => Snow Patrol
[title] => Eyes Open
)
)
[_table:protected] => Album Object
(
[_name:protected] => album
[_db:protected] => Zend_Db_Adapter_Pdo_Mysql Object
(
[_pdoType:protected] => mysql
[_config:protected] => Array
(
[host] => localhost
[username] => hezihao
[password] => 703563
[dbname] => flea_demo
[options] => Array
。。。。。。。。。。。。。。
view页面的
<?php foreach($this->albums as $album) : ?>
出现报错:
Warning: Invalid argument supplied for foreach() in /wwwroot/zend/application/views/scripts/index/index.phtml on line 11
求教是什么啊?