使用foreach调用SQL查询记录


Call an SQL query record with foreach

我想从SQL中调用一条记录:

$up_recs = $db->get_results("SELECT RID,note FROM notes"); 
if ($up_recs > NULL)
    { 
    foreach($up_recs as $rec)
        { 
          echo $rec['note']."<br/>";          
        } 
    } 

出现错误:

类stdClass的对象不能转换为字符串

? ?

使用

echo $rec->note."<br/>";
不是

echo $rec['note']."<br/>";