Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a max number of records to load #42

Open
JoolsMcFly opened this issue Nov 29, 2024 · 1 comment
Open

Add a max number of records to load #42

JoolsMcFly opened this issue Nov 29, 2024 · 1 comment

Comments

@JoolsMcFly
Copy link
Contributor

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 added a commit to JoolsMcFly/shapefile that referenced this issue Dec 11, 2024
JoolsMcFly added a commit to JoolsMcFly/shapefile that referenced this issue Dec 11, 2024
add a max number of records to load
fixes phpmyadmin#42
JoolsMcFly added a commit to JoolsMcFly/shapefile that referenced this issue Dec 11, 2024
add a max number of records to load
fixes phpmyadmin#42
JoolsMcFly added a commit to JoolsMcFly/shapefile that referenced this issue Dec 11, 2024
add a max number of records to load
fixes phpmyadmin#42
@williamdes
Copy link
Member

$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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants