Форуми / Craftwork / Server-side / Back to PHP MySQL: A question!

Probably a general question ... but still

GHengeveld
#33261 24.02.2012 18:07

If you put an SQL query (like $db->query() in Siena or sed_sql_query() in Genoa) within a foreach/for/while loop, the query will be executed for every iteration of the loop. This is considered bad practice because its very inefficient. However in some cases it's the only option you have. If you're going to do a SELECT query it's better to include it in the first query, outside of the loop if possible.