此处客户A 和客户B 向一个供应商发送消息,供应商点击客户A 消息,并且只想打开特定的客户A 消息不会混合它们。但是我收到来自客户A和客户B的消息的输出。请帮我解决这个问题。
模型
[public function customer_to_supply() {
$this->db->select('*');
$this->db->from('communication');
$this->db->join('supplier_otherdetails', 'supplier_otherdetails.supplierid_fk = communication.supplier_id');
$this->db->join('customer_registration', 'communication.Customer_id=customer_registration.id');
//$this->db->join('communication', 'communication.product_id=contact_supplier.product_id');
$where = "communication.From' =>'customer'";
$this->db->where($where);
$query = $this->db->get();
$results = \[\];
if ($query->num_rows() > 0) {
$results = $query->result();
}
return $results;
}
控制器
public function supplier_communication() {
$supp_id = $this->input->post('suppid');
$product_id = $this->input->post('proid');
$cust_id = $this->input->post('custid');
$this->session->userdata('cust',$cust_id);
$result1 = $this->Profile_model->fetch_Data($product_id);
$Userid = $this->session->userdata('id');
$result3 = $this->session->userdata('tt');
$data3 = array(
'message' => $this->input->post('messagee'),
'supplier_id' => $supp_id,
'product_id' => $product_id,
'Customer_id' => $cust_id,
'From' => $result3,
);
$this->Profile_model->data_insertt($data3);
redirect('welcome/messageview');
}
答案 0 :(得分:2)
您必须将客户的ID($ customer_id)传递给您的模型函数。以下是您重新设计的功能:
public function customer_to_supply($customerId) {
$qry = $this->db->select('*')
->from('communication')
->join('supplier_otherdetails', 'supplier_otherdetails.supplierid_fk = communication.supplier_id')
->join('customer_registration', 'communication.Customer_id=customer_registration.id')
->where('communication.From', 'customer')
->where('communication.Customer_id', $customerId)
->get();
if ($qry->num_rows() > 0)
return $qry->result_array();
return FALSE;
}