i have array more than 70000 elements,i m using batch and i declared batch will fetch 5000 data at one batch ,everthing is fine.
and if i need second batch data ,then how to call fetchdata() function
i have array more than 70000 elements,i m using batch and i declared batch will fetch 5000 data at one batch ,everthing is fine.
and if i need second batch data ,then how to call fetchdata() function
use batch() like in docs
foreach (Model::find()->batch(5000) as $batchFrom5000) {
foreach($batchFrom5000 as $oneModel) {
// ...
}
}
because batch implements Iterator
thanku for help
it is coming like this
Array
(
[0] => Array
(
[address] =>
[time] => 2014-11-09 19:57:29
[device_id] => 10
[speed] => 8.099355000000001
)
[1] => Array
(
[address] =>
[time] => 2014-11-09 19:57:59
[device_id] => 10
[speed] => 11.4470884
)
[2] => Array
(
[address] =>
[time] => 2014-11-09 19:58:29
[device_id] => 10
[speed] => 18.790503599999997
)
)
2nd batch--------------------------
Array
(
[0] => Array
(
[address] =>
[time] => 2014-11-10 19:58:59
[device_id] => 10
[speed] => 21.058323
)
[1] => Array
(
[address] =>
[time] => 2014-11-10 19:59:29
[device_id] => 10
[speed] => 7.8833722
)
[2] => Array
(
[address] =>
[time] => 2014-11-11 20:00:00
[device_id] => 10
[speed] => 3.779699
)
)
then again i want all batches in in one array,how i do that ?
i have 70000 records and i m just using batch and again storing them in one array and using that array for loop processing,is it good way,it will low the memory and time for processing .
records can be more than 300000
Array
(
[0] => Array
(
[address] =>
[time] => 2014-11-09 19:57:29
[device_id] => 10
[speed] => 8.099355000000001
)
[1] => Array
(
[address] =>
[time] => 2014-11-09 19:57:59
[device_id] => 10
[speed] => 11.4470884
)
[2] => Array
(
[address] =>
[time] => 2014-11-09 19:58:29
[device_id] => 10
[speed] => 18.790503599999997
)
[3] => Array
(
[address] =>
[time] => 2014-11-10 19:58:59
[device_id] => 10
[speed] => 21.058323
)
[4] => Array
(
[address] =>
[time] => 2014-11-10 19:59:29
[device_id] => 10
[speed] => 7.8833722
)
[5] => Array
(
[address] =>
[time] => 2014-11-11 20:00:00
[device_id] => 10
[speed] => 3.779699
)
)
i m doing coz query will not take time so on server it will not take load
Perhaps it would be easier to user paginator?
http://www.yiiframework.com/doc-2.0/yii-data-pagination.html