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

Query::count() can return int|string but always returns int #753

Closed
Tigrov opened this issue Sep 20, 2023 · 1 comment
Closed

Query::count() can return int|string but always returns int #753

Tigrov opened this issue Sep 20, 2023 · 1 comment

Comments

@Tigrov
Copy link
Member

Tigrov commented Sep 20, 2023

Query::count() can return int|string

* @return int|string Number of records. The result may be a string depending on the underlying database engine and
* to support integer values higher than a 32bit PHP integer can handle.
*
* Note: Make sure you quote column names in the expression.
*/
public function count(string $sql = '*'): int|string;

But always returns int

db/src/Query/Query.php

Lines 294 to 300 in fb4c084

public function count(string $sql = '*'): int|string
{
return match ($this->emulateExecution) {
true => 0,
false => is_numeric($count = $this->queryScalar("COUNT($sql)")) ? (int) $count : 0,
};
}

@Tigrov Tigrov mentioned this issue Nov 15, 2023
@vjik
Copy link
Member

vjik commented Nov 16, 2023

Done by #777

@vjik vjik closed this as completed Nov 16, 2023
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

No branches or pull requests

2 participants