doctrine orm 控制台执行 sql 命令,显示异常,永远显示:0 rows affected。而不会显示对应的记录 #7355

Closed
opened 2026-01-22 15:50:33 +01:00 by admin · 2 comments
Owner

Originally created by @vkviyu on GitHub (Apr 12, 2024).

Bug Report

Q A
BC Break No
Version doctrine/orm 3.1.0 php8.1.27

Summary

在使用Doctrine的dbal:run-sql命令执行SQL查询时,没有正确地输出查询结果,而是显示"0 rows affected"。

Current behavior

当我运行php doctrine.php dbal:run-sql "show databases"命令时,我期望看到我所有的数据库列表。但是,实际上我看到的输出是"0 rows affected",并没有显示任何数据库。

How to reproduce

  1. 在doctrine.php文件中,设置数据库连接参数。如下图:
    image

  2. 在终端中,运行php doctrine.php dbal:run-sql "show databases"命令。如下图:
    image

Expected behavior

我期望dbal:run-sql命令能正确地输出SQL查询的结果。在这个例子中,我期望看到我所有的数据库列表。我不确定这个 bug 在新版本的 doctrine/orm 中是否得到了解决,但因为一些原因我无法去升级我的 php 版本。

Originally created by @vkviyu on GitHub (Apr 12, 2024). ### Bug Report | Q | A |------------ | ------ | BC Break | No | Version | doctrine/orm 3.1.0 php8.1.27 #### Summary 在使用Doctrine的`dbal:run-sql`命令执行SQL查询时,没有正确地输出查询结果,而是显示"0 rows affected"。 #### Current behavior 当我运行`php doctrine.php dbal:run-sql "show databases"`命令时,我期望看到我所有的数据库列表。但是,实际上我看到的输出是"0 rows affected",并没有显示任何数据库。 #### How to reproduce 1. 在doctrine.php文件中,设置数据库连接参数。如下图: ![image](https://github.com/doctrine/orm/assets/90970572/a04a503c-4c81-4e5c-8dcc-52c6120c2998) 2. 在终端中,运行`php doctrine.php dbal:run-sql "show databases"`命令。如下图: ![image](https://github.com/doctrine/orm/assets/90970572/7334e340-7bd2-4dd2-8a33-6664863b84bf) #### Expected behavior 我期望`dbal:run-sql`命令能正确地输出SQL查询的结果。在这个例子中,我期望看到我所有的数据库列表。我不确定这个 bug 在新版本的 doctrine/orm 中是否得到了解决,但因为一些原因我无法去升级我的 php 版本。
admin added the Invalid label 2026-01-22 15:50:33 +01:00
admin closed this issue 2026-01-22 15:50:33 +01:00
Author
Owner

@derrabus commented on GitHub (Apr 12, 2024):

Please write issues in English, please.

@derrabus commented on GitHub (Apr 12, 2024): Please write issues in English, please.
Author
Owner

@ywisax commented on GitHub (May 15, 2024):

It is because "dbal:run-sql" recognize your sql as a statement, not a query.
You can use "force-fetch" option to force run query.

Check \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand::doExecute

@ywisax commented on GitHub (May 15, 2024): It is because "dbal:run-sql" recognize your sql as a statement, not a query. You can use "force-fetch" option to force run query. Check \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand::doExecute
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7355