0
Controller.php这样
public function action_user() {
$user_list = DB::select()->from('users')->execute();
// print_r($user_list);
$this->template->content = View::factory('user')
->bind('user_list',$user_list);
}
财产迭代使用循环和打印他变量。但我得到这个错误“ErrorException [ Notice ]: Trying to get property of non-object
”。如果我打印该变量为$user_list
,它正在打印为数组。
views.php
<?php echo $user_list; ?> //printing array
<?php
foreach ($user_list as $user):
echo $user->username; //getting error here
endforeach;
?>
这意味着你的'$ user_list'数组中的内容都不是对象。 – thatidiotguy
@thatidiotguy你能告诉我如何解决这个问题。 – user2681579
我没有什么可以说的,以帮助你解决这个问题,我告诉过你你遇到的问题。 – thatidiotguy