Ninjakreborn Posted September 11, 2007 Share Posted September 11, 2007 I have a really large system that pulls lot's of stuff from a database. From about 4-5 different queries it runs arrays of data into arrays from the fields. I have a products array on the first one which collects customers, products and other information. As follows [customerid] [customername] [customerid] [products] [productid and information in this array] Basically this is the array setup that is created at first. However when it goes through future database structures new customers might get added entirely (which should add a new customer id and customer details). Or some NEW products might get added(which need to add without having a chance of overwriting current projects. Then again some products might have data that need's to be added to that specific product. Does anyone have a tutorial, tips, tricks on writing "intellegent" arrays? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted September 11, 2007 Author Share Posted September 11, 2007 I have all of this in the $products array. If I do $products for the first one $products1 for the second loop $products2 for the third and then do array merge at the end will all the data filter in together as I described? Quote Link to comment Share on other sites More sharing options...
effigy Posted September 11, 2007 Share Posted September 11, 2007 How about an array of arrays? $data = array( array( 'customer_id' => 1, ), ... ); Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted September 11, 2007 Author Share Posted September 11, 2007 It is, there are multiple arrays. The main array contains a list of customer keys with information in that. Then a products array inside of that with a list of product information. Now, I am trying something(getting 3 different arrays and adding them together with +) I hope that works. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 11, 2007 Share Posted September 11, 2007 I'm confused. You said you have a large system that builds these arrays with data from the database. You then say that new entries would be added to the database and you're not sure how to insert this data into the array. Are you saying that this array is pre-built somewhere else? Another way of phrasing that question would be are you not querying directly from the DB each time you access this data? If the answer is yes then I have to wonder if there's not a more efficient way of querying the database for the data you need. How about providing a (small) example of what this array ultimately looks like using print_r() as well as your table structure. Then we can maybe help you query for the data directly in the format you want it. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted September 11, 2007 Author Share Posted September 11, 2007 I can't mess with the models. Only the controllers and view files. I have another developer that handles all the models. Basically (I can't reveal much) but basically there are 3 databas calls. Which gather data. The query calls provide all the data that i need to form the arrays. It's just I am having a hard time getting them to fall into place correctly. Because of my lack in information I might be on my own. I just don't want to accidentally reveal anything that might get me in trouble with the client. The system, code, and app are all closed source and for internal usage. So I can't accidentally reveal anything that will get me screwed. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 Sounds like a full's errand. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted September 11, 2007 Author Share Posted September 11, 2007 I got it. Basically to simplify my original question. "How do you merge heavily multi-dimensional arrays?" To answer my on question in one sentence. "Look for a function on php.net under "array_merge()" in the users comments that is called "multimerge()"." Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.