Controller
public function getback(Request $request)
{
$chart = DB::table('BirthChart_1')
->where('FileId', 123)
->get();
return $chart;
}
output be like
[{"FileId":123,"k1":3,"k2":4,"k3":null,"k4":null,"k5":null,"k6":5,"k7":null,"k8":null,"k9":null,"k10":null}]
I want to get access each and every column separately , I put like that
return $chart["k1"];
got error ...
my main task is take the each column's data send into script
您将得到一个行数组,请尝试:
return $chart[0]["k1"];
Controller be like
public function getback(Request $request)
{
$chart = DB::table('BirthChart_1')
->where('FileId', 123)
->get();
foreach ($chart as $key ) {
$f[] = [$key->k1,$key->k2,$key->k3,$key->k4,$key->k5,$key->k6,$key->k7,$key->k8,$key->k9,$key->k10];
}
return response()->json($f);
}
output of the result
[[3,4,null,null,null,5,null,null,null,null]]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.