Speed/Efficiency Question: Large array into DB

From: Date: Tue, 11 Oct 2005 16:28:17 +0000
Subject: Speed/Efficiency Question: Large array into DB
Groups: php.general 
Request: Send a blank email to php-general+get-223903@lists.php.net to get a copy of this message
Hi All, Not being a professional programmer I am looking for some advice about the best way to do the following: I have a large multidimensional array (up to 7Mb) It contains a list of categories in a fairly normal Cat_ID and Parent_ID arrangement. The array also contains a great deal of superfluous information which I want to ignore. I wish to walk through the entire array, select 4 key/value pairs from each sub-array and write those to my Database (Keys are: Cat_ID, Parent_ID, CatName, CatLevel). I wish to ignore all other key/values in each array. I'm guessing that I should use array_walk_recursive() and apply my test for valid keys then write this into my db... But, should I do this for each iteration, or make a new array with just the information I need then write that into my DB? And do I use a transaction/commit block and try to do the whole thing in one db-write or again, INSERT on each step through my array? Oh yes, the key names in the array correspond to field names in my database. Sorry it's a bit long-winded... Thanks in advance for any suggestions. Alan

« previous php.general (#223903) next »