mysql database with a tables for prodcuts. this tables has 11000+ products. those 11,000 products are from 3 different distributors (identified in a column).
what I am doing is calling the database 3 different times for each distributor (distributor names: 21, 31, 41).
so I makes the call and get a recordset with ~5600 products.
I then download the up-to-date inventory file from the respective distributor. I parse the file into a multidimentional array. this array ($dist_data) has about 7800 arrays in it. each one with the product details.
I need to go through the database results and look in that array to see if the product exists... if it doesnt then it flags for review and be removed if the distributor no longer carries it. if it does exist then it check to see if the price needs to be updated or the qty needs to be updated. if it does then it processes that.
so here is my problem. right now I have it doing a while on the db results (so will loop ~5600 times) in each while is does a foreach on the array untill it finds a match.
is there a better way of doing this? so right now I am doing a foreach on an array with over 7000 sub arrays over 5600 times. I hope I explained myself... here is a code example:
Code: Select all
$rsr_products = $db->Execute("SELECT products_quantity, products_id, products_model, products_price, product_src_cost FROM products WHERE product_distributor = '21' or product_distributor = '20'");
while(!$rsr_products->EOF){
foreach($rsr_data as $key => $val){
if($rsr_data[$key][0] == $rsr_products->fields['products_model']){
$product_match = $rsr_data[$key];
break;
}
}
}