Re: PHP Pear DB - Importing an external LAGRE .sql file
| From: | Mike D'Ambrogia | Date: | Fri, 01 Aug 2008 15:20:31 +0000 |
| Subject: | Re: PHP Pear DB - Importing an external LAGRE .sql file | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-29121@lists.php.net to get a copy of this message | ||
1. not usually a problem unless there is a network issue
2. I'd remove the visual formatting
3. shouldn't be a problem
I've found that when dealing with large amounts of data I use :
INSERT INTO /|tbl_name|/ (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
This provides *much* faster turnaround than:
INSERT INTO /|tbl_name|/ (a,b,c) VALUES(1,2,3);
INSERT INTO /|tbl_name|/ (a,b,c) VALUES(4,5,6);
INSERT INTO /|tbl_name|/ (a,b,c) VALUES(7,8,9);
the 2nd style will cause page timeouts with thousands of inserts if you are trying to do the inserts through a webpage interface -- you could use set_time_limit(0); to work around the page timeouts but you'd be left waiting for much longer than needed
md
On 7/31/2008 4:03 PM, liran tal wrote:
Hey Guys, I have tried to read a large (about 800kb) .sql file (INSERTs with lots of values) into a variable and then use that to populate the database with $res = $dbSocket->query($sql); (where $sql is the entire file) but I'm receiving DB errors. I have successfully imported the file as it is by using "mysql -u user -p database < backup.sql". I'm guessing it's one of: 1. The file is too large for DB to hand off to the database server 2. The file contrains \n which might cause DB to act all wacky 3. $dbSocket->query($sql); may not be the correct method of doing this I'm open to suggestions... any alternatives for doing that? Thanks. Regards, Liran.