3 years ago

need help with query in db with huge row

Posted 3 years ago by rehanskrill

i am writing an api for one of my project so i am facing php error my table as around 900K row method :1 my code

$products = Product::where('buyer', 0)->where('cat_id', 1)->get();
$keyby = $products->keyBy('product_id');
 $datas= gzcompress($keyby);
$params = base64_encode($this->_fnEncrypt($datas, $this->user->key));
//data will be encrypted with user key and wii send to request url by curl
// optional $result = $this->_sendRequest(['data' => $params]);

when i use method one i always get this type error i put memory_limit to 5GB but always same

PHP Fatal error: Out of memory (allocated 1705771008) (tried to allocate 2 bytes)

method 2:

Product::where('buyer', 0)->where('cat_id',1)->chunk(10000, function($products) {   
 $keyby= $products->keyBy('product_id');
//but it will chunk 10000 row at once i need to get all rows then i need to encrypt them.

is there anyway to collect all data by my query then encrypt them. and every row should in in key by product_id with json encrypted ?

data format


Please sign in or create an account to participate in this conversation.