shapefile icon indicating copy to clipboard operation
shapefile copied to clipboard

Add a max number of records to load

Open JoolsMcFly opened this issue 1 year ago • 1 comments

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?

JoolsMcFly avatar Nov 29 '24 16:11 JoolsMcFly

$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

williamdes avatar Dec 16 '24 21:12 williamdes

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

williamdes avatar Sep 10 '25 15:09 williamdes