2014-08-29 3 views
1

db에서 데이터를 가져 오려고하는데 mysqli fetch() 함수가 페치되지 않고 작동하지 않고 false를 반환합니다. 아래에 내가 사용하고 도움이 제발 기능입니다.mysqli fetch()가 가져 오지 않음

public function return_track_order_details($adRef,$transaction_id){ 

    $db = parent::Connect_Database(); 

    $stmt = $db->prepare("SELECT * FROM `s_b_p_h` WHERE `ad_reference` = ? AND `transaction_id` = ? LIMIT 1 "); 

    $stmt->bind_param('ss',$adRef,$transaction_id); 
    $stmt->execute(); 

    $stmt->bind_result(
         $id, 
         $date, 
         $name, 
         $email, 
         $phone, 
         $full_address, 
         $total_amount_paid, 
         $buyers_account_id, 
         $sellers_account_id, 
         $ad_reference, 
         $transaction_id, 
         $status_by_buyers, 
         $status_by_sellers, 
         $net_status 
         ); 
    if($stmt->fetch()){ 

     $id = $this->xss_clean($id); 
     $date = $this->xss_clean($date); 
     $name = $this->xss_clean($name); 
     $email = $this->xss_clean($email); 
     $phone = $this->xss_clean($phone); 
     $full_address = $this->xss_clean($full_address); 
     $total_amount_paid = $this->xss_clean($total_amount_paid); 
     $buyers_account_id = $this->xss_clean($buyers_account_id); 
     $sellers_account_id = $this->xss_clean($sellers_account_id); 
     $ad_reference = $this->xss_clean($ad_reference); 
     $transaction_id = $this->xss_clean($transaction_id); 
     $status_by_buyers = $this->xss_clean($status_by_buyers); 
     $status_by_sellers = $this->xss_clean($status_by_sellers); 
     $net_status = $this->xss_clean($net_status); 

    }else{ 
     return false; 
    } 
} 

내가 잘못하고있는 것이 있습니까?

나는 내 진술이 맞는지 확인하고 실행 여부를 확인했습니다.

+1

데이터베이스 호출시 오류 처리가 없습니다. 이 부분을 스크립트 상단에 놓고 예외가 발생하는지 확인하십시오 : mysqli_report (MYSQLI_REPORT_STRICT); – jeroen

답변

2

내가 여기에서하려고했던 것은 아주 우스운 이야기다. 어쩌면 일 때문에.

mysqli fecth가 true를 반환하는 경우에도이 함수에서 아무 것도 반환하지 않았습니다.

그래서 if ($ stmt-> fetch()) 문을 수정하여 배열을 반환합니다.

if($stmt->fetch()){ 

     $id = $this->xss_clean($id); 
     $date = $this->xss_clean($date); 
     $name = $this->xss_clean($name); 
     $email = $this->xss_clean($email); 
     $phone = $this->xss_clean($phone); 
     $full_address = $this->xss_clean($full_address); 
     $total_amount_paid = $this->xss_clean($total_amount_paid); 
     $buyers_account_id = $this->xss_clean($buyers_account_id); 
     $sellers_account_id = $this->xss_clean($sellers_account_id); 
     $ad_reference = $this->xss_clean($ad_reference); 
     $transaction_id = $this->xss_clean($transaction_id); 
     $status_by_buyers = $this->xss_clean($status_by_buyers); 
     $status_by_sellers = $this->xss_clean($status_by_sellers); 
     $net_status = $this->xss_clean($net_status); 

     return array(
       $id, 
       $date, 
       $name, 
       $email, 
       $phone, 
       $full_address, 
       $total_amount_paid, 
       $buyers_account_id, 
       $sellers_account_id, 
       $ad_reference, 
       $transaction_id, 
       $status_by_buyers, 
       $status_by_sellers, 
       $net_status 
       ); 
    } 
관련 문제