Page 1 of 1

Importing bulk existing data into separate existing sql db

Posted: Tue Oct 21, 2008 6:19 am
by simonmlewis
I have an Access file, and a MySQL database.

I need to import that data from the Access table into the existing MySQL table.

Some fieldnames differ, but I can alter them in Access before I do anything.

I'm assuming it's be some kind of "INSERT" query, but I've never done it with a bulk of existing data into a query.

Can anyone help please?

Re: Importing bulk existing data into separate existing sql db

Posted: Tue Oct 21, 2008 7:56 am
by aceconcepts
Hi Simon,

First of all you'll need to be able to read the Access file from PHP right? - Is this how you were thinking about doing it?

Re: Importing bulk existing data into separate existing sql db

Posted: Tue Oct 21, 2008 8:12 am
by deejay
I think fgetcsv is what you need to find out about. http://uk2.php.net/manual/en/function.fgetcsv.php

Something like

Code: Select all

 
$handle = fopen ("document.csv","r");
while ($data = fgetcsv ($handle, 1000, ",")) {
 
// then make an insert
}
 
you could make a new mysql table and then design some sort of filter to put the right fields in your existing database.

Hope this helps

Re: Importing bulk existing data into separate existing sql db

Posted: Tue Oct 21, 2008 8:20 am
by aceconcepts
I've used fgetcsv() numerous time before and it has always worked out perfectly.