douqian5920 2018-06-28 20:22
浏览 48

Laravel 5.3中的内存不足错误

There is an issue on Laravel 5.3 / Jesenger / MongoDB 3.0 which I reported here. The issue arises from saving or updating a field with special characters like "°ó" in mongodb, it always results in "out of memory" error.

Allowed memory size of ######### bytes exhausted (tried to allocate ********** bytes) 
//Whereas ######### is always greater than **********

My question is how can I convert the special character so that they can be safely pushed into the database. Note: I am doing batch insert and updating of like 30000 records, a good solution may put this into consideration.

// Code Sample
<?php 
class Products extends Jessenger\Mongodb\Eloquent\Model
{

}
?>
$product = new Products();
$product->name = 'Akara';
$product->sku = 'naija001';
$product->description = 'special characters like °ó in mongodb';
$product->save(); // Throws allowed memory size of 1392394984 bytes 
                  // exhausted (tried to allocate 2195914) note that 
                  // allowed memory size is greater than the allocated size

My temporal fix

$product = new Products();
$product->name = 'Akara';
$product->sku = 'naija001';
$product->description = utf8_encode('special characters like °ó in mongodb');
$product->save(); // Saved successfully
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 AT89C51控制8位八段数码管显示时钟。
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题