Question

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.

Was it helpful?

Solution

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!

OTHER TIPS

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

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