增加php中的执行时间

My web site page contains lot of queries. So it takes lot of time to execute, and ends in an error. Could you please tell me how to increase the execution time (may be the query execution) through php coding? Thanks in advance

Use max_execution_time:

ini_set('max_execution_time', 14000); // adjust value

Also make sure that your code is correctly, try to see if there is any room for improvement in the speed. For example, you should have a look at:

You can use set_time_limit function to set the number of seconds a script is allowed to run.

But my advice would be to rethink/rewrite your queries, because if you hit the php execution limit you may do too much work at the database, or you do the work inefficiently.

There is always room for improvement. Raising php execution time is only a temporary fix which is one of the most hated phrase in computer programming. So again, look at your database scheme and analyze your queries, check for indices, etc.

For high concurrency I/O you may also consider a NoSQL approach like APC or Memcached.

If this website is supposed to be for normal users, you will have to optimize your queries, no way around it. No user will want to wait more than a few seconds for a page to load, and if you're already surpassing the execution time limit, it's already way too slow! Extending the time limit is not a solution.

If, OTOH, this page is supposed to be more of a maintenance script, you should run it from the CLI or as a cron job where execution time limits don't exist.