Domanda

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.

È stato utile?

Soluzione

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!

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top