An async MySQL client for PHP, optimizing database interactions with efficient non-blocking capabilities. Perfect for responsive, high-performance applications.
So this pull request doesn't have to be merged as there might be a better way to handle this, but essentially due to the way packet is parsed, the columns are out of order only when the result set contains null columns. Since PHP arrays are always ordered based on insertion order (they are basically just maps), this line https://github.com/amphp/mysql/blob/56a5a9c54ec21e88a8db257aed88c8cceceb3a12/src/Internal/ConnectionProcessor.php#L1137 doesn't do what it intends to do. PHP arrays are ordered based on insertion order, so all null columns are always at the beginning of the result row.
This change just sorts the array keys using ksort. It's a brute fix.
So this pull request doesn't have to be merged as there might be a better way to handle this, but essentially due to the way packet is parsed, the columns are out of order only when the result set contains null columns. Since PHP arrays are always ordered based on insertion order (they are basically just maps), this line https://github.com/amphp/mysql/blob/56a5a9c54ec21e88a8db257aed88c8cceceb3a12/src/Internal/ConnectionProcessor.php#L1137 doesn't do what it intends to do. PHP arrays are ordered based on insertion order, so all null columns are always at the beginning of the result row.
This change just sorts the array keys using
ksort
. It's a brute fix.