Question

i am trying to upload a .csv file.. and at the same time inserting the data from csv to mysql fr this to work i have written this:

CONTROLLLER:

$file_path = './public/projects/mycsvfile.csv';
if (($handle = fopen($file_path, "r")) !== FALSE) {
    while (($csv = fgetcsv($handle, 10000000, ',','"','\\')) !== FALSE) {
          $this->Dbmodel->insert_csv($csv);
    }
}

MODEL:

function insert_csv($csv) {
    $data = array(
        'project_name' => $csv[0],
        'task_type' => $csv[1],
        'company_id' => $csv[2],
        'mobile_number' => $csv[3]
        );
    $this->db->insert('projects', $data);
}

the above code works fine for me.. it fetch's all the data from csv to mysql database..

but when i see the results in the db..the column mobile_number only displays the first 3 digit out of 10.

ex: 978 instead of 9789789781

any suggest or help would be a great help.. thanks in advance

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top