Hey guys. I'm having a very strange problem. The issue consists of the Paginator exceeding PHP's memory limit since, I guess, it tries to retrieve the entire database table instead of getting only the 50 "current" rows as instructed by the 'limit' value. And here comes the intriguing part. It works just fine on PHP 5.6 but exceeds the memory limit on PHP 7. The installed PHP extensions as well as the configuration of 5.6 and 7 are all the same. I used EasyApache 4 to install and configure everything. The version of Phalcon is 3.2.2 for both PHP 5.6 and 7.
$Paginator = new \Phalcon\Paginator\Adapter\Model([ 'data' => \ControlPanel\Models\Projects::find([ 'order' => 'id DESC' ]), 'limit' => 50, 'page' => $page ]);
Any idea why this is happening and what I can do to prevent this behaviour?
P.S. Just to let you know, the memory limit for both PHP 5.6 and 7 is set to the healthy 32 MB. The database table I'm trying to paginate is nearly 140 MB, and if I increase the memory limit, the issue disappears. However, increasing the memory limit is not a solution by itself, so I'd like to get to the root cause of this.