Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我们可以在一个控制器中使用2个回购协议吗?(Symfony 4.4)_Symfony - Fatal编程技术网

我们可以在一个控制器中使用2个回购协议吗?(Symfony 4.4)

我们可以在一个控制器中使用2个回购协议吗?(Symfony 4.4),symfony,Symfony,我在一个Symfony后端和角度前端工作,并在连接2之前测试后端 我正在尝试使用一个事件来更新两个表上的数据,但没有成功,我想知道在一个方法中使用两个repo是否合适(我尝试从索引一开始): 加载索引页面后(在twig中,测试后端代码时),我会收到一条错误消息: An exception occurred while executing 'SELECT t0.id AS id_1, t0.shop_id AS shop_id_2, t0.pack_id AS pack_id_3, t0.

我在一个Symfony后端和角度前端工作,并在连接2之前测试后端

我正在尝试使用一个事件来更新两个表上的数据,但没有成功,我想知道在一个方法中使用两个repo是否合适(我尝试从索引一开始):

加载索引页面后(在twig中,测试后端代码时),我会收到一条错误消息:

    An exception occurred while executing 'SELECT t0.id AS id_1, t0.shop_id AS shop_id_2, t0.pack_id AS pack_id_3, t0.adapte_gaucher AS adapte_gaucher_4, t0.crit1 AS crit1_5, t0.crit2 AS crit2_6, t0.crit3 AS crit3_7 FROM products_info_organisation t0 WHERE t0.id = ?' with params [5]:

SQLSTATE[42S22]: Column not found: 1054 Champ 't0.adapte_gaucher' inconnu dans field list
我可以在控制器中使用2个回购吗? 谢谢

编辑:

我尝试了Cerad解决方案,当我尝试更新时,我收到以下消息,但没有对数据库执行任何操作。我尝试了Inmariebero的解决方案来清除缓存(全局和元数据单独清除,仍然是相同的消息)。 λphp bin/控制台原则:schema:update--dump-sql

 The following SQL statements will be executed:

 ALTER TABLE products_info_organisation ADD adapte_gaucher INT DEFAULT NULL, CHANGE shop_id shop_id INT DEFAULT NULL, CHANGE pack_id pack_id INT DEFAULT NULL, CHANGE crit1 crit1 VARCHAR(20) DEFAULT NULL, CHANGE crit2 crit2 VARCHAR(20) DEFAULT NULL, CHANGE crit3 crit3 VARCHAR(20) DEFAULT NULL;
 ALTER TABLE products_info_organised CHANGE shop_id shop_id INT DEFAULT NULL, CHANGE pack_id pack_id INT DEFAULT NULL, CHANGE adapte_gaucher adapte_gaucher INT DEFAULT NULL, CHANGE triABC triABC INT DEFAULT NULL, CHANGE triACB triACB INT DEFAULT NULL, CHANGE tri_id tri_id INT DEFAULT NULL, CHANGE crit1 crit1 VARCHAR(20) DEFAULT NULL, CHANGE crit2 crit2 VARCHAR(20) DEFAULT NULL, CHANGE crit3 crit3 VARCHAR(20) DEFAULT NULL;
我不确定出了什么问题

我甚至尝试了将数据发送到角度前方的方法:

        public function index(ProductsInfoOrganisedRepository $productsInfoOrganisedRepository, ProductsInfoOrganisationRepository $productsInfoOrganisationRepository)
    {
//        return $this->json($productsInfoOrganisedRepository->findAll(), 200, []);
        return $this->json($productsInfoOrganisationRepository->findAll(), 200, []);
//        return $this->json($productsInfoOrganisedRepository->findAll(). $productsInfoOrganisationRepository->findAll(), 200, []);
    }

我仍然收到相同的错误消息,就好像我只使用Symfony一样。

似乎条令元数据已经过时,尝试清理缓存似乎条令元数据已经过时,尝试清理缓存根据日志文件中的错误,我认为错误位于实体映射中,请检查表中是否存在列
adapte\u gaucher
,是否正确设置了映射

cat var/log/dev.log | grep-CRITICAL
错误:

[2021-01-07 15:38:06] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: "An exception occurred while executing 'SELECT t0.id AS id_1, t0.shop_id AS shop_id_2, t0.pack_id AS pack_id_3, t0.adapte_gaucher AS adapte_gaucher_4, t0.crit1 AS crit1_5, t0.crit2 AS crit2_6, t0.crit3 AS crit3_7 FROM products_info_organisation t0 WHERE t0.id = ?' with params [5]:  SQLSTATE[42S22]: Column not found: 1054 Champ 't0.adapte_gaucher' inconnu dans field list" at C:\wamp64\www\shops\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractMySQLDriver.php line 79 {"exception":"[object] (Doctrine\\DBAL\\Exception\\InvalidFieldNameException(code: 0): An exception occurred while executing 'SELECT t0.id AS id_1, t0.shop_id AS shop_id_2, t0.pack_id AS pack_id_3, t0.adapte_gaucher AS adapte_gaucher_4, t0.crit1 AS crit1_5, t0.crit2 AS crit2_6, t0.crit3 AS crit3_7 FROM products_info_organisation t0 WHERE t0.id = ?' with params [5]:\n\nSQLSTATE[42S22]: Column not found: 1054 Champ 't0.adapte_gaucher' inconnu dans field list at C:\\wamp64\\www\\shops\\vendor\\doctrine\\dbal\\lib\\Doctrine\\DBAL\\Driver\\AbstractMySQLDriver.php:79, Doctrine\\DBAL\\Driver\\PDO\\Exception(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Champ 't0.adapte_gaucher

问题不取决于使用的存储库数量,您可以根据需要使用许多repo,因此,请检查映射

根据日志文件中的错误,我认为错误位于实体映射中,请检查表中是否存在列
adapte\u gaucher
,并且映射设置正确

cat var/log/dev.log | grep-CRITICAL
错误:

[2021-01-07 15:38:06] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: "An exception occurred while executing 'SELECT t0.id AS id_1, t0.shop_id AS shop_id_2, t0.pack_id AS pack_id_3, t0.adapte_gaucher AS adapte_gaucher_4, t0.crit1 AS crit1_5, t0.crit2 AS crit2_6, t0.crit3 AS crit3_7 FROM products_info_organisation t0 WHERE t0.id = ?' with params [5]:  SQLSTATE[42S22]: Column not found: 1054 Champ 't0.adapte_gaucher' inconnu dans field list" at C:\wamp64\www\shops\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractMySQLDriver.php line 79 {"exception":"[object] (Doctrine\\DBAL\\Exception\\InvalidFieldNameException(code: 0): An exception occurred while executing 'SELECT t0.id AS id_1, t0.shop_id AS shop_id_2, t0.pack_id AS pack_id_3, t0.adapte_gaucher AS adapte_gaucher_4, t0.crit1 AS crit1_5, t0.crit2 AS crit2_6, t0.crit3 AS crit3_7 FROM products_info_organisation t0 WHERE t0.id = ?' with params [5]:\n\nSQLSTATE[42S22]: Column not found: 1054 Champ 't0.adapte_gaucher' inconnu dans field list at C:\\wamp64\\www\\shops\\vendor\\doctrine\\dbal\\lib\\Doctrine\\DBAL\\Driver\\AbstractMySQLDriver.php:79, Doctrine\\DBAL\\Driver\\PDO\\Exception(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Champ 't0.adapte_gaucher

问题不取决于使用的存储库数量,您可以根据需要使用多个repo,因此,请检查映射

是的,您可以使用任意数量的存储库。错误消息意味着您的条令实体映射与数据库架构不匹配。试着运行:bin/console-doctor:schema:update--dump-sqlHello,能给我们看看dev.log吗?我想看到errorsPlease分享更多细节-为什么这样不行?给定的错误消息并不表示与问题相关的任何问题。另外,为什么不通过DI注入这些存储库?@NicoHaase,我不知道(DI)依赖注入是什么意思?我从来没用过。我想看看这是怎么回事。我认为,在我的例子中,当我在Twig渲染中测试时,它不起作用,但最后,我应该创建一个以Angular渲染的json文件。但SQL才是最让人烦恼的me@AndreyMashukov,这是dev.log。谢谢,您可以使用任意数量的存储库。错误消息意味着您的条令实体映射与数据库架构不匹配。试着运行:bin/console-doctor:schema:update--dump-sqlHello,能给我们看看dev.log吗?我想看到errorsPlease分享更多细节-为什么这样不行?给定的错误消息并不表示与问题相关的任何问题。另外,为什么不通过DI注入这些存储库?@NicoHaase,我不知道(DI)依赖注入是什么意思?我从来没用过。我想看看这是怎么回事。我认为,在我的例子中,当我在Twig渲染中测试时,它不起作用,但最后,我应该创建一个以Angular渲染的json文件。但SQL才是最让人烦恼的me@AndreyMashukov,这是dev.log。谢谢,这可能是问题的原因,有时Symfony中的奇怪错误可以通过缓存删除来修复,也可能是问题的原因,有时Symfony中的奇怪错误可以通过缓存删除来修复