Answer the question
In order to leave comments, you need to log in
How to get all records from Entity in Doctrine?
Good afternoon.
Self-written framework. Doctrine is used, with which I am still superficially familiar. Repositories for tables (for example, automatically, as in Symfony) are not defined separately. There are two classes for polling:
namespace Entities;
use \RN\registry,
Doctrine\Common\Collections\ArrayCollection;
/**
* @Table(name="rn_interview_tickets")
*/
class interview extends base_entity {
/** @Id @Column(type="integer") @GeneratedValue()*/
protected $id = null;
...
/** типы опросов
* @OneToOne(targetEntity="Entities\interviewTypes", inversedBy="interview")
* @JoinColumn(name="id_ticket_type", referencedColumnName="id")
*/
private $types;
...
namespace Entities;
/**
* @Entity
* @Table(name="rn_interview_ticket_types")
*/
class interviewTypes extends base_entity {
/** @Id @Column(type="integer") @GeneratedValue()*/
protected $id = null;
...
/**
* @OneToOne(targetEntity="Entities\interview", mappedBy="types")
*/
private $interview;
public function getTypesList() {
...
...
$o = $this->getObject(); // объект сущности опроса Entities/interview.php
$em = Registry::getInstance() -> getEntityManager();
$types = $em -> getRepository( get_class( $o -> getTypes() ) ) -> findAll();
...
Answer the question
In order to leave comments, you need to log in
You have incorrect mappings.
I was not very good at understanding what you wanted to depict here... It follows from your classes that interviews can be of many types at the same time, and not vice versa?
But, no matter how it should be - in fact you should still have a 1:N relationship, not 1:1, this is where the main mistake is.
Change the association type, then from the OneToMany
outside you will have a collection of entities, from where you can get them.
Aside note: read at your leisure PSR-1 , PSR-2 , PSR-12
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question