- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8k
Implement mysqli_fetch_column #6798
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
Conversation
d6e8caf    to
    243d14f      
    Compare
  
    | Accompanying RFC: https://wiki.php.net/rfc/mysqli_fetch_column | 
0eb8c61    to
    757d1fd      
    Compare
  
            
          
                ext/mysqli/mysqli.stub.php
              
                Outdated
          
        
      |  | ||
| function mysqli_fetch_row(mysqli_result $result): array|null|false {} | ||
|  | ||
| function mysqli_fetch_column(mysqli_result $result, int $column = 0): null|int|string|false {} | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't it also return float in INT_AND_FLOAT native mode?
757d1fd    to
    05ad183      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good (assuming RFC accepted)
2ca3539    to
    73969d4      
    Compare
  
    While only the method is mentioned in the RFC and the Migration guide, a procedural version of the same was also implemented. Includes unit tests. Refs: * https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.mysqli.mysqli_fetch_column * https://wiki.php.net/rfc/mysqli_fetch_column * php/php-src#6798 * php/php-src@54222a6
(mentioned in new features, but not in the new functions list) > `mysqli_result::fetch_column()` has been added to allow fetching a single scalar value from the result set. While only the method is mentioned in the RFC and the Migration guide, a procedural version of the same was also implemented. Refs: * https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.mysqli.mysqli_fetch_column * https://wiki.php.net/rfc/mysqli_fetch_column * php/php-src#6798 * php/php-src@54222a6
* PHP 8.1 | MigrationGuide/New functions: add missing functions [1] (mentioned in new features, but not in the new functions list) > GD: > * Avif support is now available through the `imagecreatefromavif()` and > `imageavif()` functions, if libgd has been built with avif support. Refs: * https://github.com/php/php-src/blob/f67986a9218f4889d9352a87c29337a5b6eaa4bd/UPGRADING#L245-L247 * php/php-src#7026 * php/php-src@81f6d36 * PHP 8.1 | MigrationGuide/New functions: add missing functions [2] (mentioned in new features, but not in the new functions list) > `mysqli_result::fetch_column()` has been added to allow fetching a single scalar value from the result set. While only the method is mentioned in the RFC and the Migration guide, a procedural version of the same was also implemented. Refs: * https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.mysqli.mysqli_fetch_column * https://wiki.php.net/rfc/mysqli_fetch_column * php/php-src#6798 * php/php-src@54222a6 Co-authored-by: jrfnl <jrfnl@users.noreply.github.com> Closes GH-1448.
* PHP 8.1 | MigrationGuide/New functions: add missing functions [1] (mentioned in new features, but not in the new functions list) > GD: > * Avif support is now available through the `imagecreatefromavif()` and > `imageavif()` functions, if libgd has been built with avif support. Refs: * https://github.com/php/php-src/blob/f67986a9218f4889d9352a87c29337a5b6eaa4bd/UPGRADING#L245-L247 * php/php-src#7026 * php/php-src@81f6d36 * PHP 8.1 | MigrationGuide/New functions: add missing functions [2] (mentioned in new features, but not in the new functions list) > `mysqli_result::fetch_column()` has been added to allow fetching a single scalar value from the result set. While only the method is mentioned in the RFC and the Migration guide, a procedural version of the same was also implemented. Refs: * https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.mysqli.mysqli_fetch_column * https://wiki.php.net/rfc/mysqli_fetch_column * php/php-src#6798 * php/php-src@54222a6 Co-authored-by: jrfnl <jrfnl@users.noreply.github.com> Closes phpGH-1448.
This is WIP but I am looking for suggestions to improve.
mixedbetter thannull|int|string|false?This should work almost exactly the same as PDO fetchColumn with the only difference that MySQL doesn't have a boolean type so the function can never return true (it will return false if no more rows are available).