krizzangel Posted February 11, 2010 Share Posted February 11, 2010 i have a problem with my query where the time limit exceeded (30secs). heres my code: $query = "select COUNT(*) as doble, product_s_desc as model_no from jos_vm_product group by product_s_desc having doble > 1"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $s_desc = $row[1]; $query2="select product_sku, MAX(wintron_price) from jos_wintron_ebay where product_sku in (select product_sku from jos_vm_product where product_s_desc='$s_desc') group by product_sku limit 1"; $result2= mysql_query($query2); while($row2 = mysql_fetch_array($result2)){ $sku = $row2[0]; $update ="update jos_vm_product set product_publish ='N' where product_sku ='$sku'"; mysql_query($update); } } anyone suggesting a better code? what i need is to change the publish value for duplicate items. Quote Link to comment https://forums.phpfreaks.com/topic/191746-fatal-error-maximum-execution-time-of-30-seconds-exceeded/ Share on other sites More sharing options...
Deoctor Posted February 11, 2010 Share Posted February 11, 2010 why dont u change the execution time to max limit in php.ini file Quote Link to comment https://forums.phpfreaks.com/topic/191746-fatal-error-maximum-execution-time-of-30-seconds-exceeded/#findComment-1010647 Share on other sites More sharing options...
PravinS Posted February 11, 2010 Share Posted February 11, 2010 As you are having 2 while loops, it is going in loop execution reaching the max execution time. For that you can check your queries which will return minimum records, which will let you know that queries are proper. Also you can try to optimize your queries. Or else you have to increase you execution time. Quote Link to comment https://forums.phpfreaks.com/topic/191746-fatal-error-maximum-execution-time-of-30-seconds-exceeded/#findComment-1010649 Share on other sites More sharing options...
Mchl Posted February 11, 2010 Share Posted February 11, 2010 Running a query in a loop - never a good thing and hardly ever a necessity. Additionaly inner loop has a subquery in WHERE clause, which is very inefficient in MySQL. Query below should give you expected results: SELECT e.product_sku, MAX(e.wintron_price) FROM jos_wintron_ebay AS e INNER JOIN ( SELECT product_sku FROM jos_vm_product AS p INNER JOIN ( SELECT COUNT(*) AS doble, product_s_desc FROM jos_vm_product GROUP BY product_s_desc HAVING doble > 1 ) AS p1 ON p.product_s_desc=p1.product_s_desc ) AS p ON e.product_sku = p.product_sku GROUP BY e.product_sku LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/191746-fatal-error-maximum-execution-time-of-30-seconds-exceeded/#findComment-1010651 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.