Add a max number of records to load
Hi!
We have a use case where we need to only load the first N records of a file.
It's currently not supported but the change could be minimal.
So in \PhpMyAdmin\ShapeFile\ShapeFile::loadRecords we would need to change
$this->records[] = $record;
to
$this->records[] = $record;
if (count($this->records) >= $this->maxRecords) {
break;
}
$maxRecords could be initialized to a large value or accept int or bool and code would be
$this->records[] = $record;
if ($this->maxRecords && count($this->records) >= $this->maxRecords) {
break;
}
Thoughts?
$maxRecords could be initialized to a large value or accept int or bool and code would be
yes, why not. I prefer to avoid counting multiple times If you add tests for it, then for me it should be okay at PR review time
hi @JoolsMcFly
Do you want to open your pull-request ? Use: https://github.com/phpmyadmin/shapefile/compare/master...JoolsMcFly:shapefile:feature/limit-number-loaded-records