2013-04-08 69 views
0
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);不起作用。我如何訪問它?獲取對象與廣場的成員

回答

1

嘗試以下操作:

SELECT count(F_id_gioc_Gol) as gioc_count ... 

...

return $v->gioc_count; 

命名變量應該緩解訪問它。您也可以使用調試器或var_dump來查看如何訪問提取的計數而不命名它。

+0

謝謝..它工作忘記我可以重命名列:) – Atomico 2013-04-08 11:05:29