我试图在MySQL中打印一条记录,但是出错了。我有这个方法:
$aa = DB::select("select user from statystyki where id = '10'");
print $aa->user;
函数mysql_fetch_array
无效。
答案 0 :(得分:2)
DB::select
返回一个对象数组。如果你var_dump($aa)
,你可以看到结构,它应该是这样的:
array(
0 => object(stdClass)(
'user' => 'username'
)
)
您希望以这种方式打印用户:
$aa[0]->user;
答案 1 :(得分:0)
制作一个循环。试试这种方式
$aa = DB::select("select user from statystyki where id = '10'");
foreach($aa as $user)
{
print $user->user;
}