2017-09-24 156 views
0

我有以下MySQL查詢執行 -檢查是否MySQL查詢返回一個空結果

$stmt = $linkID1->prepare("select fstatus from cae_friends where provider_email=? and request_email=?"); 
$stmt->bind_param("ss", $uid,$row['email']); 
$stmt->execute(); 
$stmt->bind_result($fstatus); 
$stmt->fetch(); 
$stmt->close(); 

現在我怎麼確定我的查詢是否返回任何reslutset或其空。請幫助

+0

請添加相關的編程語言標籤,你使用PHP? –

+0

它的PHP語言 –

回答

0

最後,我得到了解決方案,可能不是更聰明的方式,但我的目的已經解決。我改變了查詢爲 -

$stmt = $linkID1->prepare("select count(fstatus),fstatus from cae_friends where provider_email=? and request_email=?"); 
          $stmt->bind_param("ss", $uid,$row['email']); 
          $stmt->execute(); 
          $stmt->bind_result($val,$fstatus); 
          $stmt->fetch(); 


          echo "Row Count : ".$val; 

現在$ val發出正確的輸出。 Thanks guys