I'm trying to go through a lot of records from my database to do some calculations, but to keep php memory low, I've tried using $query->batch() and $query->each(), note that $query is \kak\clickhouse\ActiveRecord instance and it throws the following exception
Exception 'Error' with message 'Call to a member function close() on array' on the line where ->batch() or ->each() were called.
I'm also using MySQL database in the same project and when getting data in batches from MySQL it works as expected.
Since this is a console part of the application, here's the full stach trace
Exception 'Error' with message 'Call to a member function close() on array'
in /websites/PROJECT/vendor/yiisoft/yii2/db/BatchQueryResult.php:87
I'm trying to go through a lot of records from my database to do some calculations, but to keep php memory low, I've tried using $query->batch() and $query->each(), note that $query is \kak\clickhouse\ActiveRecord instance and it throws the following exception Exception 'Error' with message 'Call to a member function close() on array' on the line where ->batch() or ->each() were called.
I'm also using MySQL database in the same project and when getting data in batches from MySQL it works as expected.
Since this is a console part of the application, here's the full stach trace Exception 'Error' with message 'Call to a member function close() on array'
in /websites/PROJECT/vendor/yiisoft/yii2/db/BatchQueryResult.php:87
Stack trace:
0 /websites/PROJECT/vendor/yiisoft/yii2/db/BatchQueryResult.php(77): yii\db\BatchQueryResult->reset()
1 /websites/PROJECT/console/controllers/SomeCronController.php(1249): yii\db\BatchQueryResult->__destruct()
2 [internal function]: console\controllers\SomeCronController->actionSaveNgrams('48')
3 /websites/PROJECT/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
4 /websites/PROJECT/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
5 /websites/PROJECT/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('save-ngrams', Array)
6 /websites/PROJECT/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('save-ngrams', Array)
7 /websites/PROJECT/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('expected-value-...', Array)
8 /websites/PROJECT/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('expected-value-...', Array)
9 /websites/PROJECT/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
10 /websites/PROJECT/yii(31): yii\base\Application->run()
11 {main}