mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
doctrine orm 控制台执行 sql 命令,显示异常,永远显示:0 rows affected。而不会显示对应的记录
#7355
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vkviyu on GitHub (Apr 12, 2024).
Bug Report
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
在doctrine.php文件中,设置数据库连接参数。如下图:

在终端中,运行

php doctrine.php dbal:run-sql "show databases"命令。如下图:Expected behavior
我期望
dbal:run-sql命令能正确地输出SQL查询的结果。在这个例子中,我期望看到我所有的数据库列表。我不确定这个 bug 在新版本的 doctrine/orm 中是否得到了解决,但因为一些原因我无法去升级我的 php 版本。@derrabus commented on GitHub (Apr 12, 2024):
Please write issues in English, please.
@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