php prepared语句在选择多个表时返回null

k10s72fa  于 2021-06-19  发布在  Mysql
关注(0)|答案(0)|浏览(216)

目前使用slimphp做准备语句。当我的查询是

select * FROM doctor

但是,一旦我换成

select * FROM doctor d, user u where d.doctor_nric=u.doctor_nric;

系统将返回null。我已经试过mysql了,它工作正常。知道我的代码哪部分出错了吗?

public function getAllDoctor()
{
    $stmt = $this->con->prepare("select * FROM doctor d, user u where d.doctor_nric=u.doctor_nric;");
    $stmt ->execute();
    $stmt->store_result();
    $stmt ->bind_result($doctor_nric,$doctor_name,$doctor_contact);
    $doctors = array();

    while($stmt->fetch())
    {
        $data= array();
        $data['nric']=$doctor_nric;
        $data['name']=$doctor_name;
        $data['contact']=$doctor_contact;
        $data['user_id']=$doctor_id;
        array_push($doctors,$data);
    }

    return $doctors;
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题