Pregunta

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.

¿Fue útil?

Solución

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!

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top