Skip to content

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

Merged
merged 2 commits into from
May 1, 2021

Conversation

kamil-tekiela
Copy link
Member

@kamil-tekiela kamil-tekiela commented Mar 22, 2021

This is WIP but I am looking for suggestions to improve.

  • Is mixed better than null|int|string|false?
  • How to avoid temporary zval?

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).

@kamil-tekiela kamil-tekiela force-pushed the Mysqli-fetch-column branch 4 times, most recently from d6e8caf to 243d14f Compare March 24, 2021 12:50
@cmb69
Copy link
Member

cmb69 commented Mar 30, 2021

Accompanying RFC: https://wiki.php.net/rfc/mysqli_fetch_column

@cmb69 cmb69 added the RFC label Mar 30, 2021
@kamil-tekiela kamil-tekiela force-pushed the Mysqli-fetch-column branch 2 times, most recently from 0eb8c61 to 757d1fd Compare April 4, 2021 22:52
@@ -667,6 +672,8 @@ function mysqli_fetch_object(mysqli_result $result, string $class = "stdClass",

function mysqli_fetch_row(mysqli_result $result): array|null|false {}

function mysqli_fetch_column(mysqli_result $result, int $column = 0): null|int|string|false {}
Copy link
Member

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?

Copy link
Member

@nikic nikic left a 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)

@kamil-tekiela kamil-tekiela force-pushed the Mysqli-fetch-column branch from 2ca3539 to 73969d4 Compare May 1, 2021 19:10
@kamil-tekiela kamil-tekiela merged commit 54222a6 into php:master May 1, 2021
jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request Mar 9, 2022
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
jrfnl added a commit to jrfnl/doc-en that referenced this pull request Mar 11, 2022
(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
cmb69 pushed a commit to php/doc-en that referenced this pull request Mar 11, 2022
* 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.
tiffany-taylor pushed a commit to tiffany-taylor/doc-en that referenced this pull request Jan 16, 2023
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants