0

我在这里报告了 Laravel 5.3/Jesenger/MongoDB 3.0 的一个问题。问题是由于在 mongodb 中保存或更新带有“°ó”等特殊字符的字段,它总是导致“内存不足”错误。

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

我的问题是如何转换特殊字符,以便可以安全地将它们推送到数据库中。 注意:我正在批量插入和更新 30000 条记录,一个好的解决方案可能会考虑到这一点。

// 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

我的临时修复

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

0 回答 0