首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mysqli fetch()不取

问mysqli fetch()不取
EN

Stack Overflow用户
提问于 2014-08-29 23:55:45
回答 1查看 136关注 0票数 1

我正在尝试从db中获取一些数据,但是mysqli fetch()函数没有获取/不工作,它正在返回false。下面是我正在使用的函数,请帮助。

代码语言:javascript
复制
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;
    }
}

我做错什么了吗?

我使用了也检查我的声明是否正确,也检查它是否执行。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-30 00:18:06

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

我没有从这个函数返回任何东西,即使mysqli粪返回true。

因此,我修改if($stmt->()){}语句以返回数组.

代码语言:javascript
复制
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
                );
    }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25577678

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档