主义:多重逆关系

时间:2018-11-19 11:25:28

标签: php mysql doctrine

我有以下关系表:

Relationship diagram here

我的目标是检索所有居民表格[Resident]。以下是我的代码:

public function getAllResidents(){
    $all_resident = $this->resident_repo->getAll(); //!!error thrown from here!!
}

public function getAll(){
    return $this->findAll();
}

我收到的错误消息是:

A PHP Error was encountered
Severity: Warning

Message: 
 require(/Applications/MAMP/htdocs/Final_Project/a18ux06/application/models/Proxies/__CG__EntityDoctor.php):
 failed to open stream: No such file or directory

 Filename: Proxy/AbstractProxyFactory.php

 Line Number: 209

 Backtrace:

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
 Line: 209 Function: _error_handler

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
 Line: 209 Function: require

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
 Line: 119 Function: getProxyDefinition

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php
 Line: 2707 Function: getProxy

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php
 Line: 147 Function: createEntity

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php
 Line: 69 Function: hydrateRowData

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
 Line: 150 Function: hydrateAllData

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
 Line: 888 Function: hydrateAll

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php
 Line: 181 Function: loadAll

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php
 Line: 164 Function: findBy

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/application/models/Repository/ResidentRepository.php
 Line: 13 Function: findAll

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/application/controllers/ModelTest.php
 Line: 69 Function: getAllResident

 File:
 /Applications/MAMP/htdocs/Final_Project/a18ux06/application/controllers/ModelTest.php
 Line: 21 Function: getAllResidents

 File: /Applications/MAMP/htdocs/Final_Project/a18ux06/index.php Line:
 315 Function: require_once


 Fatal error: require(): Failed opening required
 '/Applications/MAMP/htdocs/Final_Project/a18ux06/application/models/Proxies/__CG__EntityDoctor.php'
 (include_path='.:/Applications/MAMP/bin/php/php7.2.8/lib/php') in
 /Applications/MAMP/htdocs/Final_Project/a18ux06/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
 on line 209 A PHP Error was encountered

 Severity: Compile Error

 Message: require(): Failed opening required
 '/Applications/MAMP/htdocs/Final_Project/a18ux06/application/models/Proxies/__CG__EntityDoctor.php'
 (include_path='.:/Applications/MAMP/bin/php/php7.2.8/lib/php')

 Filename: Proxy/AbstractProxyFactory.php

 Line Number: 209

 Backtrace:

我不确定问题出在哪里-我才刚刚开始学习学说。是因为我的[Resident]表对于[建筑物和医生]表具有[2多对一]的关系,也就是[2 inversedBy]吗?

我已经在这里呆了一整天了!快速帮助或对我可以做的事情的引用将非常有帮助。如果需要其他东西,请告诉我。

1 个答案:

答案 0 :(得分:0)

似乎Doctrin的默认查询功能在功能上受到限制。 因此,我不得不编写自己的自定义较低级SQL查询,而不是尝试使用Doctrine默认的findfind_by等。

我使用了QueryBuilder的某些地方,而某些地方是普通的SQL查询。