选择多个表时,PHP准备的语句返回null

时间:2018-10-21 02:47:14

标签: php mysql mysqli prepared-statement slim-3

当前使用Slim PHP编写预备语句。 我可以在查询为

时进行检索
select * FROM doctor

但是,一旦我更改为

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

系统将返回空值。 我已经在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;
}

0 个答案:

没有答案