1

我已经制定了一个 Web 服务。后面有一个 MySQL-DB。网络服务需要 3 个参数。一个“From”-Value 一个 To-Value 和一个“fmt”作为格式值。像这样:

"...requests?from=2011-10-18 16:15:00&to=2013-03-19 16:30:00&fmt=csv"

我得到的是

"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 30720
 bytes) in...".

我知道这意味着什么,但我想出了以下内容。在我的选择(收集我想要返回的数据)触发之前,我只花费了大约2.75MByte内存。我的选择完成了,记忆大约是 237,75MByte。好吧,如果有大量数据我会理解,但最后我会创建一个8.1MByte很大的 csv 文件。关于 Cake 中的选择,我有什么需要了解的吗?

代码截断:

$condition = array('conditions'=> array(
                         'created_at >= "'. $this->params['url']['from'].
                         '"AND created_at <="'. $this->params['url']['to'].'"'
                         )
                   );           
$this->output_data = $this->LogRequest->find('all', $condition);
4

1 回答 1

0

我认为您正在使用ContainableBehavior.

如果是这样,您应该在执行之前将递归设置为 -1 find()

$this->LogRequest->recursive = -1;

于 2013-03-19T12:52:54.697 回答