mysqli fetch() not fetching


mysqli fetch() not fetching

我正试图从数据库中获取一些数据,但mysqli fetch()函数无法获取/不起作用,并且返回false。下面是我正在使用的功能,请帮忙。

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;
    }
}

我做错了什么?

我还使用了检查我的语句是否正确,以及检查它是否已执行。

我想在这里做的事情很有趣。也许是因为工作过度。

即使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
                );
    }