Skip to content

Conversation

@egyjs
Copy link

@egyjs egyjs commented May 22, 2025

What Changed:
Replaced:

$this->createTable($tableName, $rows[0]);

with:

$this->createTable($tableName, array_values($rows)[0]);

Why:
In cases where $rows is not zero-indexed (e.g. after a filter() or manually assigned keys), trying to access $rows[0] throws:

ErrorException: Undefined array key 0

Example:

$rows = [
    5 => ['id' => 1, 'name' => 'A'],
    6 => ['id' => 2, 'name' => 'B'],
];

Accessing $rows[0] will trigger the exception above because key 0 doesn't exist.

Fix:
array_values($rows)[0] reindexes the array numerically, so the first element is always at index 0 regardless of the original keys.

This ensures the code works correctly with any numerically keyed array.

@egyjs
Copy link
Author

egyjs commented May 31, 2025

@calebporzio

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant