0
我试图在MySQL中打印记录,但出现错误。我有这种方法:Laravel 4如何打印记录MySQL?
$aa = DB::select("select user from statystyki where id = '10'");
print $aa->user;
函数mysql_fetch_array
不起作用。
我试图在MySQL中打印记录,但出现错误。我有这种方法:Laravel 4如何打印记录MySQL?
$aa = DB::select("select user from statystyki where id = '10'");
print $aa->user;
函数mysql_fetch_array
不起作用。
做一个循环。试试这种方式
$aa = DB::select("select user from statystyki where id = '10'");
foreach($aa as $user)
{
print $user->user;
}
DB::select
返回一个对象数组。如果您var_dump($aa)
,你可以看到的结构,这应该是这样的:
array(
0 => object(stdClass)(
'user' => 'username'
)
)
您想要打印的用户是这样的:
$aa[0]->user;