我在尝试
时获得Notice: Trying to get property of non-object in
foreach ($query->fetch(PDO::FETCH_OBJ) as $row) {
echo $row->id_users;
echo $row->username;
echo $row->password;
echo $row->email;
}
当我使用print_r($query->fetch(PDO::FETCH_OBJ))
时,我正在
Class Object ( [id_users] => 1 [username] => test [password] => test [email] => test )
答案 0 :(得分:0)
通常,为了遍历记录集,你可以沿着这些方向做点什么。
while( $row = $query->fetch(PDO::FETCH_OBJ) ){
echo $row->id_users;
echo $row->username;
echo $row->password;
echo $row->email;
}