big result query bombs out

Hi all,

I have a question about this ‘simple’ query:

$clienti = Clienti::find()->all();

does not return any result and the script crashes without any exception or message being logged.

Clienti is a table with 398K rows (146MB of data according to MySQL stats).

The code bombs out at line 825 of yii2/db/Command.php, when trying to execute the pdo statement.

I guess it is a problem of exhausted memory, but is there any way to protect against it?

Thank you

The script loads too much data.

I think that you have two solution:

  1. Paginate data (if it is possible);

  2. Use Database command (http://www.yiiframework.com/doc-2.0/yii-db-command.html), to reduce amount of required memory.

Thanks for your input.

I ended up paginating, since it was a one off situation. I’ll try the other solution you propose.

Again, thanks a lot.