【发布时间】:2012-09-24 13:56:31
【问题描述】:
我使用以下Zend Framework Quick start tutorial 创建了模型。
现在在控制器中,我调用了fetchAll() 函数,并且我从模型类中获取了数组形式的值。这个数组看起来像 ...
Array
(
[0] => Admin_Model_Users Object
(
[_id:protected] => 1
[_access_id:protected] => 1
[_firstname:protected] => test
[_lastname:protected] => test
[_username:protected] => admin
[_password:protected] => 1@3$523456
[_salt:protected] =>
[_email:protected] =>
[_active:protected] => 0
[_last_access:protected] => 0
[_created:protected] => 0
)
)
现在我使用foreach 循环来获取数组的值,但这次它给出了如下错误:
消息:无效的用户属性
我已经运行foreach循环如下:
<?php
foreach($this->profile as $myprofile){
echo $myprofile->id;
} ?>
我已经尝试解决它,也在谷歌搜索上。但我没有得到任何解决方案。请告诉我,如何访问数组的值?
【问题讨论】:
-
错误似乎与粘贴的代码无关...
-
你能从模型(仅函数)和控制器中发布你的代码吗......因为你做错了所有的东西......