에서 joinColumns은 내 질문이 강하게 나는 어떤 부분이없는 모든 책을 찾기 위해 노력하고 이것 Undefined index: inverseJoinColumns while trying to define ManyToMany relationship between two entities교리 N : M 관계 정의되지 않은 인덱스 : BasicEntityPersister.php
관련이있다. 여기
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Sections", inversedBy="editedBook")
* @ORM\JoinTable(name="edited_book_has_section",
* joinColumns={
* @ORM\JoinColumn(name="edited_book_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="section_id", referencedColumnName="id")
* }
*)
*/
private $section;
내 엔티티의 구성이다 EditedBooks : -> findBy (배열 ("부"=> null가) 여기서
내 엔티티의 구성이다 섹션/**
* Bidirectional (INVERSE SIDE)
*
* @ORM\ManyToMany(targetEntity="EditedBooks", mappedBy="section")
*/
private $editedBook;
내가 받고있는 오류
Undefined index: joinColumns in BasicEntityPersister.php
는 난 단지
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Sections", inversedBy="editedBook")
* @ORM\JoinTable(name="edited_book_has_section")
*/
또는 정의를 전환과 또한 그것을 tryied하지만이 오류를받을
You cannot search for the association field '\Entity\EditedBooks#section', because it is the inverse side of an association. Find methods only work on owning side associations.
해결 방법 : 나는에서 querybuilder 내 문제를 해결하기 위해 노력 오늘 내 editedBooksRepository
$query = $qb->select('books')
->from('Bundle:EditedBooks', 'books')
->leftJoin('books.section', 'sec')
->addSelect('COUNT(sec.id) AS sec_count')
->andWhere('sec_count = 0');
그러나 다음과 같은 오류가 발생했습니다 :
An exception occurred while executing 'SELECT e0_.id AS id0, e0_.doi AS doi1, e0_.isbn_print AS isbn_print2, e0_.isbn_electronic AS isbn_electronic3, e0_.publication_date AS publication_date4, e0_.price_print AS price_print5, e0_.price_electronic AS price_electronic6, e0_.summary AS summary7, e0_.title AS title8, e0_.ongoing AS ongoing9, e0_.pages AS pages10, e0_.illustrations AS illustrations11, e0_.entry_date AS entry_date12, e0_.google_id AS google_id13, e0_.specialIssue_comment AS specialIssue_comment14, e0_.deleted AS deleted15, e0_.specialIssue_id AS specialIssue_id16, COUNT(s1_.id) AS sclr17, e0_.book_series_id AS book_series_id18, e0_.copyright_id AS copyright_id19, e0_.publisher_id AS publisher_id20 FROM edited_books e0_ LEFT JOIN edited_book_has_section e2_ ON e0_.id = e2_.editedbooks_id LEFT JOIN sections s1_ ON s1_.id = e2_.sections_id WHERE sclr17 = 0':
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sclr17' in 'where clause'
그러나 나는 sclr17이있는 것처럼 보입니다.
못생긴 해결 나는 잘 할 수있는 일이 때로는 사람이에이 아니라는 것을 알고에 사람이 무슨 상관이 : 지금 노력하고 더러운 수정 프로그램
$noSection = new Sections();
$noSection->setTitle("Sectionless");
//add all the books
$noSection->setEditedBook(new ArrayCollection($books));
//remove the assigned ones
foreach($sections as $section){
$sBooks = $section->getEditedBook();
foreach($sBooks as $b){
$noSection->removeEditedBook($b);
}
}
하지만, 나는 다른 해결책으로 인해 기쁩니다. 여기
이 답변을 찾았습니까? – Abstract