Не удается импортировать данные Excel в Mysql - PullRequest
0 голосов
/ 05 февраля 2019

Я следую шагу с этого сайта [https://www.webslesson.info/2018/04/how-to-import-excel-data-into-mysql-database-using-codeigniter.html#comment-form][1]

, но когда я пытаюсь импортировать данные, моя база данных все еще пуста

Моя функция импорта в контроллере:

 public function import()
 {
  if(isset($_FILES["file"]["name"]))
  {
   $path = $_FILES["file"]["tmp_name"];
   $object = PHPExcel_IOFactory::load($path);
   foreach($object->getWorksheetIterator() as $worksheet)
   {
    $highestRow = $worksheet->getHighestRow();
    $highestColumn = $worksheet->getHighestColumn();
    for($row=2; $row<=$highestRow; $row++)
    {
     $customer_name = $worksheet->getCellByColumnAndRow(0, $row)->getValue();
     $address = $worksheet->getCellByColumnAndRow(1, $row)->getValue();
     $city = $worksheet->getCellByColumnAndRow(2, $row)->getValue();
     $postal_code = $worksheet->getCellByColumnAndRow(3, $row)->getValue();
     $country = $worksheet->getCellByColumnAndRow(4, $row)->getValue();
     $data[] = array(
      'CustomerName'  => $customer_name,
      'Address'   => $address,
      'City'    => $city,
      'PostalCode'  => $postal_code,
      'Country'   => $country
     );
    }
   }
   $this->pppmodel->insert($data);
   echo 'Data Imported successfully';
  } 
 }

Моя модель:

public function insert($data)
 {
  $this->db->insert('tbl_customer', $data);
 }
}

Пожалуйста, помогите мне

...