为了账号安全,请及时绑定邮箱和手机立即绑定

如何搜索两个以上的关键字?

如何搜索两个以上的关键字?

PHP
慕斯709654 2021-05-07 14:09:21
我有5场名称first_name,last_name,middle_name,status和barangay_name,我想搜索根据用户想要的数据。问题只有最后一个字段名称barangay_name是正常工作。其余的不是,我的查询出了什么问题?我只检索活跃的受益人,并且内部加入tbl_beneficiary和tbl_barangay。  public function searchActiveBeneficiary($keyword) {        $sql = "SELECT tbl_beneficiary.beneficiary_id,         tbl_beneficiary.first_name, tbl_beneficiary.last_name,         tbl_beneficiary.middle_name, tbl_beneficiary.is_active,         tbl_barangay.barangay_name FROM tbl_beneficiary INNER JOIN tbl_barangay         ON tbl_barangay.barangay_id = tbl_beneficiary.barangay_id WHERE         tbl_beneficiary.is_active = 'Yes' AND tbl_beneficiary.first_name OR         tbl_beneficiary.is_active = 'Yes' AND tbl_beneficiary.last_name OR         tbl_beneficiary.is_active = 'Yes' AND tbl_beneficiary.middle_name OR         tbl_beneficiary.is_active = 'Yes' AND tbl_barangay.barangay_name LIKE         :keyword";        $stmt = $this->connection->prepare($sql);        $stmt->execute([            ":keyword" => '%' . $keyword . '%'        ]);        return $stmt->fetchAll();    }  //vue.js method  searchActiveBeneficiary : function() {        axios({            method : "GET",            url : this.urlRoot + "beneficiary/search_active_beneficiary.php?keyword=",            params : {                keyword : this.search_active_beneficiary            }        }).then(function (response){            vm.active_beneficiaries = response.data;            console.log(response);        });    },  <?php    include '../../private/initialize.php';    $beneficiary = new Beneficiary();    echo json_encode($beneficiary->searchActiveBeneficiary($_GET['keyword']));  ?>
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 236 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信