1

I have the csv file mail.csv that contain data as below:

   type,timeLogged,t
d,2012-08-24 00:00:57+0200,2012-08-24 00:00:45+0200,noreply@news.camera-factice.com,myriam.yall34@gmail.com,
d,2012-08-24 00:00:57+0200,2012-08-24 00:00:45+0200,noreply@118-bonsplans.com,toulouse@texa.fr,
b,2012-08-24 00:00:57+0200,2012-08-22 23:59:31+0200,noreply@lemeilleur-duweb.com
d,2012-08-24 00:00:57+0200,2012-08-24 00:00:57+0200,diffusion@news.antivol-voiture.com

I want to insert all these data into mysql using php.In fact I don not know how to fix this.Anyone help me please,Many thanks,

Clyde Lobo
  • 9,126
  • 7
  • 34
  • 61
user1629258
  • 39
  • 2
  • 7
  • please have a look on this post http://stackoverflow.com/questions/11461313/import-csv-file-directly-into-mysql-database?rq=1 – Renjith K N Aug 28 '12 at 05:14

1 Answers1

0

You can use the CakePHP Utils Plugin that includes a CsvImportBehavior. You just need to pass the csv file path. And its method ($this->Model->importCSV('mail.csv');) will return you the array containing all records. Then you can simply manipulate it according to your requirement and can save into the database very easily.

Arun Jain
  • 5,476
  • 2
  • 31
  • 52