(ZF2+Doctrine2) Find,FindBy doesn't return any result or error message

I'm working on a small project in wich i'm using ZF2 + Doctrine2. I have a doctrine entity whith the following description:

<?php

namespace Akplanu\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Exemplaire
 *
 * @ORM\Table(name="exemplaire", indexes={@ORM\Index(name="fk_Exemplaire_Livre1_idx", columns={"Liv_id"}), @ORM\Index(name="fk_Exemplaire_Donateur1_idx", columns={"Don_id"}), @ORM\Index(name="fk_Exemplaire_Origin_1_idx", columns={"Origin_id"}), @ORM\Index(name="fk_Exemplaire_Etat_Livre1_idx", columns={"Etlv_id"})})
 * @ORM\Entity(repositoryClass="Akplanu\Repository\ExemplaireRepository")
 */
class Exemplaire
{
    /**
     * @var integer
     *
     * @ORM\Column(name="Expl_id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var integer
     *
     * @ORM\Column(name="Expl_numEntr", type="integer", nullable=false)
     */
    private $numEntre;

    /**
     * @var string
     *
     * @ORM\Column(name="Expl_lieuEdit", type="string", length=45, nullable=false)
     */
    private $lieuEdit;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="Expl_datEdit", type="date", nullable=false)
     */
    private $datEdit;

    /**
     * @var boolean
     *
     * @ORM\Column(name="Expl_tome", type="integer", nullable=true)
     */
    private $tome;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="Expl_datDon", type="date", nullable=true)
     */
    private $dateDon;

    /**
     * @var float
     *
     * @ORM\Column(name="Expl_prix", type="float", precision=10, scale=0, nullable=true)
     */
    private $prix;

    /**
     * @var string
     *
     * @ORM\Column(name="Expl_comment", type="text", nullable=true)
     */
    private $comment;

    /**
     * @var \Akplanu\Entity\Livre
     *
     * @ORM\ManyToOne(targetEntity="Akplanu\Entity\Livre")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="Liv_id", referencedColumnName="Liv_id")
     * })
     */
    private $livre;

    /**
     * @var \Akplanu\Entity\Donateur
     *
     * @ORM\ManyToOne(targetEntity="Akplanu\Entity\Donateur")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="Don_id", referencedColumnName="Don_id", nullable=true)
     * })
     */
    private $donateur;


    /**
     * @var \Akplanu\Entity\OrigineExemplaire
     *
     * @ORM\ManyToOne(targetEntity="Akplanu\Entity\OrigineExemplaire")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="Origin_id", referencedColumnName="Origin_id", nullable=false)
     * })
     */
    private $origine;

    /**
     * @var \Akplanu\Entity\EtatLivre
     *
     * @ORM\ManyToOne(targetEntity="Akplanu\Entity\EtatLivre")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="Etlv_id", referencedColumnName="Etlv_id", nullable=false)
     * })
     */
    private $etat;

    /**
     * @ORM\Column(name="Expl_datEntree" ,type="date" , nullable=false)
     */
    private $dateEntree;

    /**
     * @ORM\Column(name="Expl_estEmprunter" ,type="boolean" , nullable=false)
     */
    private $estEmprunter;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set numEntre
     *
     * @param integer $numEntre
     * @return Exemplaire
     */
    public function setNumEntre($numEntre)
    {
        $this->numEntre = $numEntre;

        return $this;
    }

    /**
     * Get numEntre
     *
     * @return integer 
     */
    public function getNumEntre()
    {
        return $this->numEntre;
    }

    /**
     * Set lieuEdit
     *
     * @param string $lieuEdit
     * @return Exemplaire
     */
    public function setLieuEdit($lieuEdit)
    {
        $this->lieuEdit = $lieuEdit;

        return $this;
    }

    /**
     * Get lieuEdit
     *
     * @return string 
     */
    public function getLieuEdit()
    {
        return $this->lieuEdit;
    }

    /**
     * Set datEdit
     *
     * @param \DateTime $datEdit
     * @return Exemplaire
     */
    public function setDatEdit($datEdit)
    {
        $this->datEdit = $datEdit;

        return $this;
    }

    /**
     * Get datEdit
     *
     * @return \DateTime 
     */
    public function getDatEdit()
    {
        return $this->datEdit;
    }

    /**
     * Set tome
     *
     * @param boolean $tome
     * @return Exemplaire
     */
    public function setTome($tome)
    {
        $this->tome = $tome;

        return $this;
    }

    /**
     * Get tome
     *
     * @return boolean 
     */
    public function getTome()
    {
        return $this->tome;
    }

    /**
     * Set dateDon
     *
     * @param \DateTime $dateDon
     * @return Exemplaire
     */
    public function setDateDon($dateDon)
    {
        $this->dateDon = $dateDon;

        return $this;
    }

    /**
     * Get dateDon
     *
     * @return \DateTime 
     */
    public function getDateDon()
    {
        return $this->dateDon;
    }

    /**
     * Set prix
     *
     * @param float $prix
     * @return Exemplaire
     */
    public function setPrix($prix)
    {
        $this->prix = $prix;

        return $this;
    }

    /**
     * Get prix
     *
     * @return float 
     */
    public function getPrix()
    {
        return $this->prix;
    }

    /**
     * Set comment
     *
     * @param string $comment
     * @return Exemplaire
     */
    public function setComment($comment)
    {
        $this->comment = $comment;

        return $this;
    }

    /**
     * Get comment
     *
     * @return string 
     */
    public function getComment()
    {
        return $this->comment;
    }

    /**
     * Set livre
     *
     * @param \Akplanu\Entity\Livre $livre
     * @return Exemplaire
     */
    public function setLivre(\Akplanu\Entity\Livre $livre )
    {
        $this->livre = $livre;

        return $this;
    }

    /**
     * Get livre
     *
     * @return \Akplanu\Entity\Livre 
     */
    public function getLivre()
    {
        return $this->livre;
    }

    /**
     * Set donateur
     *
     * @param \Akplanu\Entity\Donateur $donateur
     * @return Exemplaire
     */
    public function setDonateur(\Akplanu\Entity\Donateur $donateur )
    {
        $this->donateur = $donateur;

        return $this;
    }

    /**
     * Get donateur
     *
     * @return \Akplanu\Entity\Donateur 
     */
    public function getDonateur()
    {
        return $this->donateur;
    }



    /**
     * Set origine
     *
     * @param \Akplanu\Entity\OrigineExemplaire $origine
     * @return Exemplaire
     */
    public function setOrigine(\Akplanu\Entity\OrigineExemplaire $origine )
    {
        $this->origine = $origine;

        return $this;
    }

    /**
     * Get origine
     *
     * @return \Akplanu\Entity\OrigineExemplaire 
     */
    public function getOrigine()
    {
        return $this->origine;
    }

    /**
     * Set etat
     *
     * @param \Akplanu\Entity\EtatLivre $etat
     * @return Exemplaire
     */
    public function setEtat(\Akplanu\Entity\EtatLivre $etat )
    {
        $this->etat = $etat;

        return $this;
    }

    /**
     * Get etat
     *
     * @return \Akplanu\Entity\EtatLivre 
     */
    public function getEtat()
    {
        return $this->etat;
    }


    public function getDateEntree()
    {
        return $this->dateEntree;
    }

    public function setDateEntree($dateEntree)
    {
         $this->dateEntree = $dateEntree;
    }
    public function getEstEmprunter()
    {
        return $this->estEmprunter;
    }

    public function setEstEmprunter($estEmprunter)
    {
        $this->estEmprunter = $estEmprunter;
    }




}

And a repository with the following code:

<?php 
namespace Akplanu\Repository;

use Akplanu\Entity\Exemplaire;

use Doctrine\ORM\EntityRepository;

class ExemplaireRepository extends EntityRepository
{

    /**
     * add or update an exemplaire
     */
    public function save(Exemplaire $exemplaire)
    {
        $this->getEntityManager()->persist($exemplaire);
        $this->getEntityManager()->flush();
    }

    /**
     * delete a list exemplaire base on ids array
     */
    public function delete($idsExemplaire)
    {
        $dql = "DELETE FROM Akplanu\Entity\Exemplaire d WHERE d.id IN (:idsExemplaire)";
        $query = $this->getEntityManager()->createQuery($dql);
        $query->setParameter('idsExemplaire',$idsExemplaire);
        $query->execute();
    }

    /**
     * find Exemplaire by id
     */
    public function findById($id)
    {
        return $this->find((int)$id);                   
    }

    /**
     * find exemplaire by name
     */
    public function findByNumeroEntree($numeroEntree)
    {
        return $this->findBy(array('numeroEntree'=>$numeroEntree),array('numeroEntree'=>'asc'));
    }

    /**
     * retrieve list of all exemplaire
     */
    public function getAll()
    {
        return $this->findAll();
    }

    public function getListExemplairesPouvantEtreEmprunter()
    {
        $dql = "SELECT e,l FROM Akplanu\Entity\Exemplaire e
                JOIN e.livre l
                WITH e.estEmprunter = false";
        $query = $this->getEntityManager()->createQuery($dql);
        return $query->getResult();
    }
}

?>

When i call the ExemplaireRepository::findById() method via my service in the contoller(by using ajax request), the request doesn't return any result even if i edit the method as follow:

/**
 * find Exemplaire by id
 */
public function findById($id)
{

    $dql = "SELECT e,l,d,o,t FROM Akplanu\Entity\Exemplaire e 
            JOIN e.livre l
            JOIN e.donateur d
            JOIN e.origine o
            JOIN e.etat t
            WHERE e.id=:id";
    $query = $this->getEntityManager()->createQuery($dql);
    $query->setParameter('id', $id);
    return $query->getResult();

}

In FireBug Console i have a wainting icon than is shown indefinitly without any error message, but the ExemplaireRepository::getListExemplairesPouvantEtreEmprunter() is working well!

Has somebody already face that kind of problem? Where can be it cause? And How can i solve it. Thank you in advance.

Answers


This is most likely a setup error in your code. I would suggest using the doctrine modules for Zend Framework 2.

https://github.com/doctrine/DoctrineORMModule

https://github.com/doctrine/DoctrineModule

The readmes explain how to install the modules using composer .


Need Your Help

Deserialize XML file

c# xml serialization xml-serialization deserialization

I have an XML file containing 4 different strings, but I am having trouble deserializing the file. Could someone help me with this?

SharedPreferences not updating

android settings sharedpreferences

I'm still getting my feet wet in android. I'm trying to save a season and year to represent a default "semester," but my changes aren't applying. I've logged and confirmed that my settings.edit().p...