public function get_Gol($idComp, $idSq){
global $wpdb;
$row = $wpdb->get_results($wpdb->prepare("SELECT count(F_id_gioc_Gol) FROM `ASD_Partite` p
LEFT JOIN ASD_CALCIO_Partite_Gol cpg ON p.id = cpg.F_id_dett_partita
WHERE p.F_id_comp = %d AND (p.F_id_sq1 = %d OR p.F_id_sq2 = %d) AND F_id_gioc_Gol = %d", $idComp, $idSq, $idSq, $this->idGioc));
foreach ($row as $key => $v){
return $v->count(F_id_gioc_Gol);
}
问题是$v->count(F_id_gioc_Gol);
不起作用。我怎么才能访问它?
答案 0 :(得分:1)
尝试以下方法:
SELECT count(F_id_gioc_Gol) as gioc_count ...
...
return $v->gioc_count;
命名变量应该可以轻松访问它。您也可以使用debugger或var_dump来查看如何在不命名的情况下访问获取的计数。