我有一个表,它有一个customer_number
字段,有些数字重复多次,但我只想得到在字段中唯一的数字。
public function set_unique()
{
$e = $_POST['e'];
if($e == 1)
{
$one = $this->db->get('calls_details');
foreach($one->result() as $data) {
$two = $this->db->where('Customer_Number', $data->Customer_Number)
->get('calls_details');
if($two->num_rows() == 1) {
foreach($two->result() as $data2) {
$three = $this->db->where('Customer_Number', $data2->Customer_Number)
->update('calls_details', ['unique_id'=>1]);
}
}
}
}
}
}
// defining array in which we get form values
$dataDB = ['first_name' => $this->input->post('first_name'),
'second_name' => $this->input->post('second_name'),
'email' => $this->input->post('email'),
];
// load model
$this->load->model('Customer');
//set record id, which we need to be updated
$this->Customer->id = $uniqueCustomerIDNumber;
//save record
$this->Customer->save();