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

Explain why the number of affected rows can be a string #5872

Merged
merged 2 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ Every non-abstract schema manager class must implement them in order to satisfy
# BC Break: The number of affected rows is returned as `int|string`

The signatures of the methods returning the number of affected rows changed as returning `int|string` instead of `int`.
If the number is greater than `PHP_INT_MAX`, the number of affected rows may be returned as a string if the driver supports it.

# BC Break: Dropped support for `collate` option for MySQL

Expand Down
2 changes: 2 additions & 0 deletions src/Driver/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function quote(string $value): string;

/**
* Executes an SQL statement and return the number of affected rows.
* If the number of affected rows is greater than the maximum int value (PHP_INT_MAX),
* the number of affected rows may be returned as a string.
*
* @throws Exception
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/OCI8/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function quote(string $value): string
* @throws Exception
* @throws Parser\Exception
*/
public function exec(string $sql): int|string
public function exec(string $sql): int
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oci_num_rows returns int|false.

{
return $this->prepare($sql)->execute()->rowCount();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/PDO/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(private readonly PDO $connection)
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}

public function exec(string $sql): int|string
public function exec(string $sql): int
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PDO::exec() returns int|false.

{
try {
$result = $this->connection->exec($sql);
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLSrv/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function quote(string $value): string
return "'" . str_replace("'", "''", $value) . "'";
}

public function exec(string $sql): int|string
public function exec(string $sql): int
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlsrv_rows_affected returns int|false.

{
$stmt = sqlsrv_query($this->connection, $sql);

Expand Down