Symfony find field

I have a Developers entity and table named CodeUserReference

class CodeUserReference
 * @var integer
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
protected $id;

 *@ORM\ManyToOne(targetEntity="Artel\CustomerBundle\Entity\Developers", inversedBy="newreference")
protected $alluser;

 * @ORM\Column(type="string", length=255)
protected $codereference;

and Developers

class Developers extends SUser
 * @var string
 * @ORM\Column(name="email", type="string", length=255,  unique=false, nullable=false)
 * @Assert\Length(min=3, max=255)
 * @Assert\NotBlank
protected $email;
 * @ORM\ManyToMany(targetEntity="Artel\CustomerBundle\Entity\CodeUserReference", inversedBy="alluser")
protected $newreference;

I have get query in my Action

public function profileGetAction(Request $request)
    $em = $this->getDoctrine()->getManager();

    $code_user_reference = $em->getRepository('ArtelCustomerBundle:CodeUserReference')->findOneByCodereference($request->query->get('reference'));
    $user_by_email = $em->getRepository('ArtelCustomerBundle:Developers')->findOneByEmail($request->query->get('email'));
    if (!empty($code_user_reference) && empty($user_by_email))
        $id = $code_user_reference->getAlluser()->getId();
        $user_by_reference = $em->getRepository('ArtelCustomerBundle:Developers')->findOneById($id);

        $user_by_reference_json = $em->getRepository('ArtelCustomerBundle:Developers')->createQueryBuilder('d')
            ->where(' :id')
            ->setParameter('id', $code_user_reference->getAlluser()->getId())

        echo json_encode( array('user' => $user_by_reference_json));
    If(empty($code_user_reference) && !empty($user_by_email))

I get Id in code_user_reference, then I find Developers objects with this ID, then I create a QueryBuilder and in this QueryBuilder I find the developers objects again, for JSON table. I find this very hard, who knows easier practics ?


There is certanly mismapping.

if you have @ORM\ManyToOne from one site, there should be @ORM\OneToMany from other.

Or, if you need many-to-many relationship, there should be @ORM\ManyToMany on both entities.

Also, relation should be mapped at one side. If you have (targetEntity="Artel\CustomerBundle\Entity\Developers", inversedBy="newreference") it means it should be mapped here

something like

@ORM\ManyToOne(targetEntity="Artel\CustomerBundle\Entity\Developers", inversedBy="newreference")
@ORM\JoinColumn(name="id_developer", referencedColumnName="id")

and at the other side must be mappedBy instead of inversedBy

* @ORM\OneToMany(targetEntity="Artel\CustomerBundle\Entity\CodeUserReference", mappedBy="alluser")

Need Your Help

Is my package structure correct?

java package

What should be the hierarchy of packages?

Heap profiling on ARM

embedded profiling arm heap-memory

I am developing a GUI-heavy C++ application on a Freescale MX51-based board Linux 2.6.35. I would like to perform heap profiling.