我有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
提交
取消