Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Iterator broken (?) with more than 32 rows from ORM

Hello.

I've created simple snippet to test situation:

$eol = php_sapi_name() == 'cli' ? "\n" : '<br/>';

echo "PHP     : " . phpversion()            . $eol;
echo "Phalcon : " . \Phalcon\Version::get() . $eol;

$testIssue = function ($limit) use ($eol) {
    $comments  = Comments::find(['limit' => $limit]);
    $className = get_class($comments);
    foreach ($comments as $comment) {
        if ($comment === false)   echo "$limit | $className | FAIL$eol";
        if (!empty($comment->id)) echo "$limit | $className | OK $eol";
        break;
    }
};

$limits = range(30, 35);
foreach ($limits as $limit)
    $testIssue($limit);

And output is:

PHP     : 5.6.8-1+deb.sury.org~precise+4
Phalcon : 2.0.1
30 | Phalcon\Mvc\Model\Resultset\Simple | OK
31 | Phalcon\Mvc\Model\Resultset\Simple | OK
32 | Phalcon\Mvc\Model\Resultset\Simple | OK
33 | Phalcon\Mvc\Model\Resultset\Simple | FAIL
34 | Phalcon\Mvc\Model\Resultset\Simple | FAIL
35 | Phalcon\Mvc\Model\Resultset\Simple | FAIL

(O_O)

Same result if i run CLI Task (\Phalcon\CLI\Console) or (\Phalcon\Mvc\Micro).

In database logs i see same queries for all iterations:SELECT * FROM `comments` LIMIT N, where N is $limit.

How to solve this? Thanks.

I have same issue



10.7k
Accepted
answer