Re: [PHP-DB] Load MySQL from a variable
G'day CPT John W. Holmes and Rory >> AFAIK, LOAD DATA INFILE will only work off a file. So you would have to >> create a temp file. Another option is to create a multiple value insert >> query e.g. > Agree that LOAD DATA INFILE will probably still be faster overall, even with > the file write. Try each and see, though. I kinda figured this would be the case. As there could potentially be a huge number of rows I was worried about doing an insert. I ended up writing a temp file, loading it and then deleting it. It's quite fast and seems to work just fine. Cheers and thanks again for the suggestions kim PS. Does everyone else sometimes get multiple copies of posts? I posted just one message but I got it three times via the list. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Load MySQL from a variable
From: "Rory McKinley" <[EMAIL PROTECTED]> > AFAIK, LOAD DATA INFILE will only work off a file. So you would have to > create a temp file. Another option is to create a multiple value insert > query e.g. > > INSERT INTO arb_table (arb_column_1...arb_column_n) > VALUES (arb_value_1..arb_value_n), (arb_value_1..arb_value_n), . Making the above query should be as simple as: $query = 'INSERT INTO arb_table (arb_column_1, arb_column_n) VALUES (' . str_replace("\n","),\n(",$file_data) . ')'; where $file_data is your adjusted CSV file in a variable. > Although LOAD DATA INFILE is, i think, the fastest way to get data into > MySQL, if you first have to create a temp file, the additional nuisance and > time factors might make the above query a valid alternative. Agree that LOAD DATA INFILE will probably still be faster overall, even with the file write. Try each and see, though. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Load MySQL from a variable
From: "Kim Kohen" <[EMAIL PROTECTED]> > I have some data from Filemaker Pro which needs to have a lot of > search/replacing done before importing into MySQL. I have used ereg_replace > in PHP and end up with a variable holding the correct data. (there are > several hundred rows of data in the variable) > > Is it possible to use Load data infile with a variable or will I need to > write out a temp file and then load that? The temp file would probably be the best/fastest way to do it. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Load MySQL from a variable
Hi Kim AFAIK, LOAD DATA INFILE will only work off a file. So you would have to create a temp file. Another option is to create a multiple value insert query e.g. INSERT INTO arb_table (arb_column_1...arb_column_n) VALUES (arb_value_1..arb_value_n), (arb_value_1..arb_value_n), . Although LOAD DATA INFILE is, i think, the fastest way to get data into MySQL, if you first have to create a temp file, the additional nuisance and time factors might make the above query a valid alternative. Regards Rory McKinley Nebula Solutions +27 82 857 2391 [EMAIL PROTECTED] "There are 10 kinds of people in this world, those who understand binary and those who don't" (Unknown) - Original Message - From: "Kim Kohen" <[EMAIL PROTECTED]> To: "PHP" <[EMAIL PROTECTED]> Sent: Tuesday, October 21, 2003 6:24 AM Subject: [PHP-DB] Load MySQL from a variable > G'day all, > > I have some data from Filemaker Pro which needs to have a lot of > search/replacing done before importing into MySQL. I have used ereg_replace > in PHP and end up with a variable holding the correct data. (there are > several hundred rows of data in the variable) > > Is it possible to use Load data infile with a variable or will I need to > write out a temp file and then load that? > > Cheers and thanks > > kim > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php