Ver Mensaje Individual
  #10 (permalink)  
Antiguo 09/05/2013, 14:17
daymerrf
 
Fecha de Ingreso: febrero-2013
Mensajes: 66
Antigüedad: 11 años, 2 meses
Puntos: 0
Respuesta: Consulta DQL no devuelve un valor

Código:
<?php

class Serie
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="nombre", type="string", length=255)
     */
    private $nombre;

    /**
     * @var string
     *
     * @ORM\Column(name="imagen", type="string", length=255)
     * @Assert\Image(maxSize = "1M")
     * @Assert\NotBlank()
     */
    private $imagen;

    /**
     * @var string
     *
     * @ORM\Column(name="sinopsis", type="text")
     */
    private $sinopsis;

    /**
     * @var \string
     *
     * @ORM\Column(name="ano_publicacion", type="string", length=4, nullable=true)
     */
    private $ano_publicacion;

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

    /**
     * @var string
     *
     * @ORM\Column(name="creador", type="string", length=255,  nullable=true)
     */
    private $creador;
     
    /**
     * @var string
     *
     * @ORM\Column(name="slug", type="string", length=255)
     */
    private $slug;
    
    /**
     * @ORM\OneToMany(targetEntity="Capitulo", mappedBy="serie")
     */
    protected $capitulos;

     /**
     * @ORM\OneToOne(targetEntity="slider")     
     */
    protected $slider;
    
    /**
    * @ORM\OneToMany(targetEntity="SerieGenero", mappedBy="serie")
    */
    protected $generos;
    
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set nombre
     *
     * @param string $nombre
     * @return Serie
     */
    public function setNombre($nombre)
    {
        $this->nombre = $nombre;
    
        return $this;
    }

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

    /**
     * Set imagen
     *
     * @param string $imagen
     * @return Serie
     */
    public function setImagen($imagen)
    {
        $this->imagen = $imagen;
    
        return $this;
    }

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

    /**
     * Set sinopsis
     *
     * @param string $sinopsis
     * @return Serie
     */
    public function setSinopsis($sinopsis)
    {
        $this->sinopsis = $sinopsis;
    
        return $this;
    }

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

    /**
     * Set ano_publicacion
     *
     * @param \DateTime $anoPublicacion
     * @return Serie
     */
    public function setAnoPublicacion($anoPublicacion)
    {
        $this->ano_publicacion = $anoPublicacion;
    
        return $this;
    }

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

    /**
     * Set fecha_culminacion
     *
     * @param \DateTime $fechaCulminacion
     * @return Serie
     */
    public function setFechaCulminacion($fechaCulminacion)
    {
        $this->fecha_culminacion = $fechaCulminacion;
    
        return $this;
    }

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

    /**
     * Set creador
     *
     * @param string $creador
     * @return Serie
     */
    public function setCreador($creador)
    {
        $this->creador = $creador;
    
        return $this;
    }

    /**
     * Get creador
     *
     * @return string 
     */
    public function getCreador()
    {
        return $this->creador;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->capitulos = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Add capitulos
     *
     * @param \Animes\BackendBundle\Entity\Capitulo $capitulos
     * @return Serie
     */
    public function addCapitulo(\Animes\BackendBundle\Entity\Capitulo $capitulos)
    {
        $this->capitulos[] = $capitulos;
    
        return $this;
    }

    /**
     * Remove capitulos
     *
     * @param \Animes\BackendBundle\Entity\Capitulo $capitulos
     */
    public function removeCapitulo(\Animes\BackendBundle\Entity\Capitulo $capitulos)
    {
        $this->capitulos->removeElement($capitulos);
    }

    /**
     * Get capitulos
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getCapitulos()
    {
        return $this->capitulos;
    }
    
    public function __toString() {
        return $this->nombre;
    }

    /**
     * Set slug
     *
     * @param string $slug
     * @return Serie
     */
    public function setSlug($slug)
    {
        $this->slug = $slug;
    
        return $this;
    }

    /**
     * Get slug
     *
     * @return string 
     */
    public function getSlug()
    {
        return $this->slug;
    }
    
    /**
     * Set slider
     *
     * @param \Animes\BackendBundle\Entity\slider $slider
     * @return Serie
     */
    public function setSlider(\Animes\BackendBundle\Entity\slider $slider = null)
    {
        $this->slider = $slider;
    
        return $this;
    }

    /**
     * Get slider
     *
     * @return \Animes\BackendBundle\Entity\slider 
     */
    public function getSlider()
    {
        return $this->slider;
    }

    /**
     * Add generos
     *
     * @param \Animes\BackendBundle\Entity\SerieGenero $generos
     * @return Serie
     */
    public function addGenero(\Animes\BackendBundle\Entity\SerieGenero $generos)
    {
        $this->generos[] = $generos;
    
        return $this;
    }

    /**
     * Remove generos
     *
     * @param \Animes\BackendBundle\Entity\SerieGenero $generos
     */
    public function removeGenero(\Animes\BackendBundle\Entity\SerieGenero $generos)
    {
        $this->generos->removeElement($generos);
    }

    /**
     * Get generos
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getGeneros()
    {
        return $this->generos;
    }
}
Código:
class SerieGenero
{
    /**
     * @var integer
     *
     * @ORM\Id     
     * @ORM\ManyToOne(targetEntity="Serie", inversedBy="generos") 
     * @ORM\JoinColumn(name="serie_id", referencedColumnName="id", onDelete="Cascade")
     */
    private $serie;

    /**
     * @var integer
     * 
     * @ORM\Id     
     * @ORM\ManyToOne(targetEntity="Genero", inversedBy="series")
     * @ORM\JoinColumn(name="genero_id", referencedColumnName="id", onDelete="Cascade")   
     */ 
    private $genero;
   

    /**
     * Set serie
     *
     * @param \Animes\BackendBundle\Entity\Serie $serie
     * @return SerieGenero
     */
    public function setSerie(\Animes\BackendBundle\Entity\Serie $serie)
    {
        $this->serie = $serie;
    
        return $this;
    }

    /**
     * Get serie
     *
     * @return \Animes\BackendBundle\Entity\Serie 
     */
    public function getSerie()
    {
        return $this->serie;
    }

    /**
     * Set genero
     *
     * @param \Animes\BackendBundle\Entity\Genero $genero
     * @return SerieGenero
     */
    public function setGenero(\Animes\BackendBundle\Entity\Genero $genero)
    {
        $this->genero = $genero;
    
        return $this;
    }

    /**
     * Get genero
     *
     * @return \Animes\BackendBundle\Entity\Genero 
     */
    public function getGenero()
    {
        return $this->genero;
    }
}