0

I used CodeIgniter for my back end technology. I just create one bulk insertion module for reading CSV data and insert it in the database.

But in insertion do not insert proper value like:-

Wrong value:- Brhl Castle

Right value:- Brühl Castle

Is there any way to insert the same value in a database like the right value?

In Controller my code like this:-

$dataIn['title'] = utf8_encode($data[1]);
$dataIn['latitude'] = $data[2];
$dataIn['longitude'] = $data[3];
$dataIn['country'] = utf8_encode($data[4]);
$dataIn['city'] = utf8_encode($data[5]);
$this->model->bulkInsert($dataIn);

In Model my code like this:-

function bulkInsert($dataIn, $id = '') {
    $this->db->where(array('id' => $dataIn['id']));
    $query = $this->db->get($this->TABLE);
    $result = $query->row_array();
    if ($query->num_rows() > 0) {
        $this->db->where($this->PK, $dataIn['id']);
        $this->db->update($this->TABLE, $dataIn);
    } else {
        $this->db->insert($this->TABLE, $dataIn);
    }
    setMessage('Record inserted successfully.', 'green');
}
2
  • set the mysql field collation to UTF8_general_ci
    – Vickel
    Aug 8, 2020 at 10:42
  • Thanks for your reply,It's working perfectly now.
    – Abhijit
    Aug 26, 2020 at 8:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.