Вопрос

I am developing an application in cakephp where I want to import the csv file and save the data into database.

So I need some help in reading csv file into an array after which I will do some validation and insert data into database.

I have searched a lot but could not find the solution.

Thanks in advance.

Это было полезно?

Решение

You should use CakePHP's already-existing csv datasource in a custom model.

It is here - https://github.com/cakephp/datasources/blob/master/Model/Datasource/CsvSource.php

See here for how to use them.

Then you can just use your normal $model->find() operations on it! Simple!

Другие советы

Try with fgetcsv(), here's the doc: fgetcsv()

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top