mysqli fetch()无法获取 [英] mysqli fetch() not fetching
本文介绍了mysqli fetch()无法获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从数据库中获取一些数据,但是mysqli fetch()函数无法获取/无法正常工作,并且返回的是false.以下是我正在使用的功能,请提供帮助.
I am trying to fetch some data from my db, but mysqli fetch() function is not fetching / not working and it is returning false. below is the function i am using and please help.
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;
}
}
我做错了什么吗?
我也使用过检查我的语句是否正确,并检查它是否已执行.
i have used also check if my statement is right and also check if it executed.
推荐答案
我在这里尝试做的事情很有趣.也许是因为工作过度.
It's quite funny what i was trying to do here. maybe because of over work.
即使mysqli fecth返回true,我也没有从该函数返回任何信息.
I was not returning anything from this function even if mysqli fecth returns 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
);
}
这篇关于mysqli fetch()无法获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文