English 中文(简体)
• 如何防止PHP使Fatal Error从询问结果中解救出来?
原标题:How to Prevent PHP Allowed Memory Size Fatal Error from query result?

I have a (cake) php function designed to update entries in a MySQL table; first of all it runs a query to get all the new items since a $lastImportDate, and then loops through performing various actions on the item, saving the item, saving related table information.

不幸的是,在一项特别请求的过度权重下,这种情况似乎正在崩溃。 这里有5917个条目(可能计数!)更新。 功能休息时间过去了一段时间,但最终会因“低记忆大小(斜线)”差错而死亡。

在不强迫任何人通过广泛的法典打折扣的情况下——我可以合理地采取什么战略,试图阻止这种记忆泄露,使本表无法更新?

最佳回答

You can always try setting:

ini_set( memory_limit ,  -1 );

[docs ]

more appropriate Value

或者,用以下方式来做农活:CASE < Update, 或用中选更新),或设置一个

问题回答

如同你一样,所有记录都在变数中保存。 Try 只拿到身份证,然后通过身份证号码。 你们通过支付这一款项,获得一切记录; 之后,你拯救了这一记录并揭开了数据,这样你就永远不会把很多数据储存在变量中。 如果你把所有东西都放在一个变数中,我就毫不奇怪。

增加记忆限制只是一种不好的暂时解决办法,想象需要更新100 000或100 000多份记录。 最后,你空出。

我不知道你需要完成的任务的性质。 如果您需要更新定期间隔的条目: a 壳牌照将它放到跳板上(如果你不得不每小时开张)。

If you need to perform an update every time you do an import to the DB: you can try loop{ get and process 100 records, repeat until done} Try to maximize the number of records you can process before hitting the memory limit.





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签