使用未定义的常量值 - 假定 'value'
Use of undefined constant value - assumed 'value'
Use of undefined constant value - assumed 'value' how i access?
public function idcount($id)
{
$stats = DB::table('questions')
->select( DB::raw("COUNT('id') as value"))
->where('user_id',$id)
->groupBy('user_id')
->get(
);
return $stats.value;
}
你应该使用:
return $stats[0]->value;
而不是
return $stats.value;
因为您正在使用查询生成器和 get
方法 returns 结果集合,并且您想从该集合中获取 value
列
Use of undefined constant value - assumed 'value' how i access?
public function idcount($id)
{
$stats = DB::table('questions')
->select( DB::raw("COUNT('id') as value"))
->where('user_id',$id)
->groupBy('user_id')
->get(
);
return $stats.value;
}
你应该使用:
return $stats[0]->value;
而不是
return $stats.value;
因为您正在使用查询生成器和 get
方法 returns 结果集合,并且您想从该集合中获取 value
列