Foros del Web » Programando para Internet » PHP » Symfony »

Problemas con consulta symfony

Estas en el tema de Problemas con consulta symfony en el foro de Symfony en Foros del Web. Hola Tengo este problema, tengo esta funcion: Código: public function findByname($params){ $name= $params['name']; $language= $params['language']; $em = $this->getEntityManager(); $query = $em->createQuery(' SELECT h, d FROM ...
  #1 (permalink)  
Antiguo 17/12/2012, 12:20
 
Fecha de Ingreso: abril-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 0
Pregunta Problemas con consulta symfony

Hola

Tengo este problema, tengo esta funcion:

Código:
public function findByname($params){
			$name= $params['name'];
                        $language= $params['language'];
                        
                        $em = $this->getEntityManager();
			$query = $em->createQuery('  SELECT h, d
                                                    FROM cntHBBundle:Hotels h
                                                    JOIN cntHBBundle:HotelDescriptions d 
                                                    WHERE h.hotelcode = :id 
                                                    AND d.languagecode= :language
                                                    ');
			$query->setParameter('id',$name);
                        $query->setParameter('language',$language);
			$query->setMaxResults(1);			
			$names = $query->getResult();
		return $names;
		}
Y trabaja bien, pero cuando intento hacer un SELECT a 3 tablas asi como esta:

Código:
public function findByname($params){
			$name= $params['name'];
                        $language= $params['language'];
                        
                        $em = $this->getEntityManager();
			$query = $em->createQuery(' SELECT h, d, f
                                                    FROM cntHBBundle:Hotels h
                                                    JOIN cntHBBundle:HotelDescriptions d 
                                                    JOIN cntHBBundle:Facilities
                                                    WHERE h.hotelcode = :id 
                                                    AND d.languagecode= :language
                                                    AND f.hotelcode= :id
                                                    
                                                    ');
			$query->setParameter('id',$name);
                        $query->setParameter('language',$language);
			$query->setMaxResults(1);			
			$names = $query->getResult();
		return $names;
		}
Me regresa un "Syntax error"

[Syntax Error] line 0, col 316: Error: Expected =, <, <=, <>, >, >=, !=, got 'WHERE'

Y creo que mi funcion es correcta, para ser honestos no teng ni idea que sucede, alguien me puede ayudar con esto :( ?
  #2 (permalink)  
Antiguo 17/12/2012, 12:50
Avatar de abimex
Colaborador
 
Fecha de Ingreso: marzo-2007
Ubicación: ~
Mensajes: 751
Antigüedad: 17 años, 2 meses
Puntos: 137
Respuesta: Problemas con consulta symfony

al parecer algunas variables puede que no estén presentes, estas comprobando los datos?
  #3 (permalink)  
Antiguo 17/12/2012, 13:11
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Problemas con consulta symfony

Es un typo o te falta definir el alias de Facilites ?, una sugerencia, si quieres obtener un solo resultado puedes utilizar getSingleResult(ten en cuenta que si no existe el resultado hace throw de Doctrine\Orm\NoResultException)

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #4 (permalink)  
Antiguo 17/12/2012, 14:01
 
Fecha de Ingreso: abril-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 0
Sonrisa Respuesta: Problemas con consulta symfony

Cita:
Iniciado por masterpuppet Ver Mensaje
Es un typo o te falta definir el alias de Facilites ?, una sugerencia, si quieres obtener un solo resultado puedes utilizar getSingleResult(ten en cuenta que si no existe el resultado hace throw de Doctrine\Orm\NoResultException)

Saludos.
lo que sucede esque en realidad necesito utilizar como aprox. 10 tablas,... y necesito que me regresen varios resultados :S, porque algunas tablas no se encuentran relacionadas, entonces lo que estoy intentando hacer es hacer consulta a todas las tablas que tienen la base de datos, para que de ellas saque la información correspondiente que ocupo...

y abimex, si estoy verificando los datos, y cada una de esas entitades que ingreso si son correctas, de igual forma la de facilities si existe... :S

de echo mi entidad "Facilities" esta asi:

Código:
<?
namespace cnt\HBBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use cnt\HBBundle\Entity\FacilityTypes;
use Symfony\Component\Validator\Constrainst as Assert;

/**
* @ORM\Entity()
* @ORM\Table(name="FACILITIES")
*/

class Facilities
{ 
	/**
	* @ORM\Id
    * @ORM\Column(name="HOTELCODE",type="string", length=8, nullable=false, unique=true)
    */
	protected $hotelcode;
	
	/**
	* @ORM\Id
	* @ORM\ManyToOne(targetEntity="FACILITY_TYPES", inversedBy="FACILITIES")
    * @ORM\Column(name="CODE",type="string", length=3, nullable=false)
    */
	protected $code;
	
	/**
	* @ORM\Id
	* @ORM\ManyToOne(targetEntity="FACILITY_TYPES", inversedBy="FACLITIES")
    * @ORM\Column(name="GROUP_",type="string", length=3, nullable=false)
    */
	protected $group;
	
	/**
	* @ORM\Id
    * @ORM\Column(name="ORDER_", type="string", length=8, nullable=false)
    */
	protected $order;
	
	/**
    * @ORM\Column(name="NUMBER_", type="string", length=9, nullable=true)
    */
	protected $number=null;
	
	/**
    * @ORM\Column(name="LOGIC",type="string", length=1, nullable=true)
    */
	protected $logic=null;
	
	/**
    * @ORM\Column(name="FEE",type="string", length=1, nullable=true)
    */
	protected $fee=null;
	
	/**
    * @ORM\Column(name="DISTANCE", type="string", length=9, nullable=true)
    */
	protected $distance=null;
	
	/**
    * @ORM\Column(name="WALKINGDISTANCE",type="string", length=9, nullable=true)
    */
	protected $walkingdistance=null;
	
	/**
    * @ORM\Column(name="TRANSPORTDISTANCE",type="string", length=9, nullable=true)
    */
	protected $transportdistance=null;
	
	/**
    * @ORM\Column(name="CARDISTANCE",type="string", length=9, nullable=true)
    */
	protected $cardistance=null;
	
	/**
    * @ORM\Column(name="AGEFROM",type="string", length=3, nullable=true)
    */
	protected $agefrom=null;
	
	/**
    * @ORM\Column(name="AGETO",type="string", length=3, nullable=true)
    */
	protected $ageto=null;
	
	/**
    * @ORM\Column(name="BEACHACCESS",type="string", length=1, nullable=true)
    */
	protected $beachaccess=null;
	
	/**
    * @ORM\Column(name="BEACHAPART", type="string", length=1, nullable=true)
    */
	protected $beachapart=null;
	
	/**
    * @ORM\Column(name="CONCEPT",type="string", length=100, nullable=true)
    */
	protected $concept=null;

    /**
     * Set hotelcode
     *
     * @param string $hotelcode
     * @return Facilities
     */
    public function setHotelcode($hotelcode)
    {
        $this->hotelcode = $hotelcode;
    
        return $this;
    }

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

    /**
     * Set code
     *
     * @param string $code
     * @return Facilities
     */
    public function setCode($code)
    {
        $this->code = $code;
    
        return $this;
    }

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

    /**
     * Set group
     *
     * @param string $group
     * @return Facilities
     */
    public function setGroup($group)
    {
        $this->group = $group;
    
        return $this;
    }

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

    /**
     * Set order
     *
     * @param string $order
     * @return Facilities
     */
    public function setOrder($order)
    {
        $this->order = $order;
    
        return $this;
    }

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

    /**
     * Set number
     *
     * @param string $number
     * @return Facilities
     */
    public function setNumber($number)
    {
        $this->number = $number;
    
        return $this;
    }

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

    /**
     * Set logic
     *
     * @param string $logic
     * @return Facilities
     */
    public function setLogic($logic)
    {
        $this->logic = $logic;
    
        return $this;
    }

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

    /**
     * Set fee
     *
     * @param string $fee
     * @return Facilities
     */
    public function setFee($fee)
    {
        $this->fee = $fee;
    
        return $this;
    }

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

    /**
     * Set distance
     *
     * @param string $distance
     * @return Facilities
     */
    public function setDistance($distance)
    {
        $this->distance = $distance;
    
        return $this;
    }

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

    /**
     * Set walkingdistance
     *
     * @param string $walkingdistance
     * @return Facilities
     */
    public function setWalkingdistance($walkingdistance)
    {
        $this->walkingdistance = $walkingdistance;
    
        return $this;
    }

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

    /**
     * Set transportdistance
     *
     * @param string $transportdistance
     * @return Facilities
     */
    public function setTransportdistance($transportdistance)
    {
        $this->transportdistance = $transportdistance;
    
        return $this;
    }

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

    /**
     * Set cardistance
     *
     * @param string $cardistance
     * @return Facilities
     */
    public function setCardistance($cardistance)
    {
        $this->cardistance = $cardistance;
    
        return $this;
    }

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

    /**
     * Set agefrom
     *
     * @param string $agefrom
     * @return Facilities
     */
    public function setAgefrom($agefrom)
    {
        $this->agefrom = $agefrom;
    
        return $this;
    }

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

    /**
     * Set ageto
     *
     * @param string $ageto
     * @return Facilities
     */
    public function setAgeto($ageto)
    {
        $this->ageto = $ageto;
    
        return $this;
    }

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

    /**
     * Set beachaccess
     *
     * @param string $beachaccess
     * @return Facilities
     */
    public function setBeachaccess($beachaccess)
    {
        $this->beachaccess = $beachaccess;
    
        return $this;
    }

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

    /**
     * Set beachapart
     *
     * @param string $beachapart
     * @return Facilities
     */
    public function setBeachapart($beachapart)
    {
        $this->beachapart = $beachapart;
    
        return $this;
    }

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

    /**
     * Set concept
     *
     * @param string $concept
     * @return Facilities
     */
    public function setConcept($concept)
    {
        $this->concept = $concept;
    
        return $this;
    }

    /**
     * Get concept
     *
     * @return string 
     */
    public function getConcept()
    {
        return $this->concept;
    }
}
  #5 (permalink)  
Antiguo 17/12/2012, 14:23
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Problemas con consulta symfony

Me refiero al DQL, te falta el alias de facilities y te sobra una condición, debería ser algo así:

Código DQL:
Ver original
  1. SELECT h, d, f
  2. FROM cntHBBundle:Hotels h
  3. JOIN cntHBBundle:HotelDescriptions d
  4. JOIN cntHBBundle:Facilities f
  5. WHERE h.hotelcode = :id
  6. AND d.languagecode= :language

y primero, te sugiero que si tienes lenguajes en tu app utilices alguno de los bundles para tal tarea o bien utilices los filtros de doctrine para no tener que estar declarando en cada query el idioma..., segundo, utiliza naming strategies, para nombrar campos y tablas, es bastante mas ameno que estar nombrando cada campo y tabla solo porque lo quieres en mayúscula.

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #6 (permalink)  
Antiguo 17/12/2012, 14:32
 
Fecha de Ingreso: abril-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Problemas con consulta symfony

Cita:
Iniciado por masterpuppet Ver Mensaje
Me refiero al DQL, te falta el alias de facilities y te sobra una condición, debería ser algo así:

Código DQL:
Ver original
  1. SELECT h, d, f
  2. FROM cntHBBundle:Hotels h
  3. JOIN cntHBBundle:HotelDescriptions d
  4. JOIN cntHBBundle:Facilities f
  5. WHERE h.hotelcode = :id
  6. AND d.languagecode= :language

y primero, te sugiero que si tienes lenguajes en tu app utilices alguno de los bundles para tal tarea o bien utilices los filtros de doctrine para no tener que estar declarando en cada query el idioma..., segundo, utiliza [URL="http://docs.doctrine-project.org/en/latest/reference/namingstrategy.html"]naming strategies[/URL], para nombrar campos y tablas, es bastante mas ameno que estar nombrando cada campo y tabla solo porque lo quieres en mayúscula.

Saludos.
ok gracias, y tomare en cuenta lo del nombre del campo, solo como tu me lo explicas, me sale el siguiente error, es algo que igual me habia salido antes y suponia que era con respecto al WHERE por ser operadores de comparacion lo que me solicita :S! :(

[Syntax Error] line 0, col 264: Error: Expected =, <, <=, <>, >, >=, !=, got 'f'
  #7 (permalink)  
Antiguo 17/12/2012, 14:48
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Problemas con consulta symfony

Si, my bad, sigue estando mal el DQL, los joins son en realidad con la propiedad...., no conozco las relaciones en tu caso pero seria algo así:
Código DQL:
Ver original
  1. SELECT h, d, f
  2. FROM cntHBBundle:Hotels h
  3. JOIN h.descriptions d
  4. JOIN h.facilities f
  5. WHERE h.hotelcode = :id
  6. AND d.languagecode= :language
__________________
http://es.phptherightway.com/
thats us riders :)
  #8 (permalink)  
Antiguo 17/12/2012, 14:54
 
Fecha de Ingreso: abril-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Problemas con consulta symfony

Cita:
Iniciado por masterpuppet Ver Mensaje
Si, my bad, sigue estando mal el DQL, los joins son en realidad con la propiedad...., no conozco las relaciones en tu caso pero seria algo así:
Código DQL:
Ver original
  1. SELECT h, d, f
  2. FROM cntHBBundle:Hotels h
  3. JOIN h.descriptions d
  4. JOIN h.facilities f
  5. WHERE h.hotelcode = :id
  6. AND d.languagecode= :language
lo que sucede esque no tiene relaciones las tablas... supongo que es por eso que estoy ingresando mis entidades con el "cntHBBundle", por que ninguna de ellas tiene relacion con la otra, yo me preguntaba si eso es posible cuando intento agregar asi las tablas... sin que tengan relacion.
  #9 (permalink)  
Antiguo 17/12/2012, 15:16
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Problemas con consulta symfony

Algo así a nivel de DQL no es posible, porque no lo obtienes por queries separadas ?
__________________
http://es.phptherightway.com/
thats us riders :)
  #10 (permalink)  
Antiguo 17/12/2012, 16:45
 
Fecha de Ingreso: abril-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Problemas con consulta symfony

Hice un cambio... he creado la relacion con uno de los atributos:

Código:
<?
namespace cnt\HBBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use cnt\HBBundle\Entity\CategoryDescriptions;
use cnt\HBBundle\Entity\Zones;
use Symfony\Component\Validator\Constrainst as Assert;

/**
* @ORM\Entity(repositoryClass="cnt\HBBundle\Entity\HotelsRepository")
* @ORM\Table(name="HOTELS")
*/

class Hotels 
{
    /**
    * @ORM\Id 
    * @ORM\Column(name="HOTELCODE",type="string", length=8, unique=true)
    */
    protected $hotelcode;
    /**
    * @ORM\OneToMany(targetEntity="HotelDescriptions", mappedBy="descriptions")
    */
   protected $descriptions;

   /**
    * @ORM\Column(name="NAME",type="string", length=50)
    */
    protected $name;
 
    /**
    * @ORM\OneToMany(targetEntity="CATEGORY_DESCRIPTION", mappedBy="HOTELS")
    * @ORM\Column(name="CATEGORYCODE",type="string", length=5)	
    */
    protected $categorycode;

   	/**
    * @ORM\Column(name="DESTINATIONCODE",type="string", length=3)
    */
    protected $destinationcode;
    
   /**
    * @ORM\ManyToOne(targetEntity="ZONES", inversedBy="HOTELS")
    * @ORM\Column(name="ZONECODE",type="string", length=8, nullable=true)
    */
    protected $zonecode = null;
 
    /**
    * @ORM\Column(name="CHAINCODE",type="string", length=5, nullable=true)
    */
    protected $chaincode = null;
    
    /**
    * @ORM\Column(name="LICENCE",type="string", length=15, nullable=true)
    */
    protected $licence = null;

    /**
    * @ORM\Column(name="LATITUDE",type="string", length=45, nullable=true)
    */
    protected $latitude = null;

    /**
    * @ORM\Column(name="LONGITUDE",type="string", length=45, nullable=true)
    */
    protected $longitude = null;

}
y de igual forma use asi mi función:

Código:
public function findByname($params){
			$name= $params['name'];
                        $language= $params['language'];
                        
                        $em = $this->getEntityManager();
			$query = $em->createQuery(' SELECT h, d
                                                    FROM cntHBBundle:Hotels h
                                                    JOIN h.descriptions d 
                                                    WHERE h.hotelcode = :id 
                                                    AND d.languagecode= :language                                                    
                                                     
                                                    ');
			$query->setParameter('id',$name);
                        $query->setParameter('language',$language);
			$query->setMaxResults(1);			
			$names = $query->getResult();
		return $names;
		}
Y lo que me sale ahorita es lo siguiente:

Notice: Undefined index: descriptions in /home5/punkmktc/cnt/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php line 823
  #11 (permalink)  
Antiguo 17/12/2012, 16:56
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Problemas con consulta symfony

Revisa la metadata, es correcto el mappedBy de la propiedad descriptions ?, no debería ser hotels en vez de descriptions ?, postea la entidad HotelDescriptions
__________________
http://es.phptherightway.com/
thats us riders :)
  #12 (permalink)  
Antiguo 18/12/2012, 09:25
 
Fecha de Ingreso: abril-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Problemas con consulta symfony

Cita:
Iniciado por masterpuppet Ver Mensaje
Revisa la metadata, es correcto el mappedBy de la propiedad descriptions ?, no debería ser hotels en vez de descriptions ?, postea la entidad HotelDescriptions
Código:
<?
namespace cnt\HBBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use cnt\HBBundle\Entity\Lenguages;
use Symfony\Component\Validator\Constrainst as Assert;

/** 
* @ORM\Entity(repositoryClass="cnt\HBBundle\Entity\HotelDescriptionsRepository")
* @ORM\Table(name="HOTEL_DESCRIPTIONS")
*/

class HotelDescriptions
{ 
	/**
	* @ORM\Id
        * @ORM\Column(name="HotelCode",type="string", length=8, nullable=false, unique=true)
        * @ORM\ManyToOne(targetEntity="Hotels", inversedBy="descriptions")
          */
	protected $hotelcode;
	
	/**
	* @ORM\Id
	* @ORM\ManyToOne(targetEntity="LANGUAGES", inversedBy="HOTEL_DESCRIPTIONS")
	* @ORM\Column(name="LanguageCode",type="string", length=3, nullable=false)
    */
	protected $languagecode;
	
	/**
	* @ORM\Column(name="HotelFacilities",type="string", length=2000, nullable=false)
    */
	protected $hotelfacilities;
	
	/**
	* @ORM\Column(name="HotelLocationDescription",type="string", length=2000, nullable=false)
    */
	protected $hotellocationdescription;
	
	/**
	* @ORM\Column(name="HotelRoomDescription",type="string", length=2000, nullable=false)
    */
	protected $hotelroomdescription;
	
	/**
	* @ORM\Column(name="HolelSportDescription",type="string", length=2000, nullable=false)
    */
	protected $holelsportdescription;
	
	/**
	* @ORM\Column(name="HotelMealsDescription",type="string", length=2000, nullable=false)
    */
	protected $hotelmealsdescription;
	
	/**
	* @ORM\Column(name="HotelPaymentMethods",type="string", length=2000, nullable=false)
    */
	protected $HotelPaymentMethods;
	
	/**
	* @ORM\Column(name="HotelHowToGetThere",type="string", length=2000, nullable=false)
    */
	protected $hotelhowtogetthere;
	
	/**
	* @ORM\Column(name="HotelComments",type="string", length=2000, nullable=false)
    */
	protected $hotelcomments;
   

    /**
     * Set hotelcode
     *
     * @param string $hotelcode
     * @return HotelDescriptions
     */
    public function setHotelcode($hotelcode)
    {
        $this->hotelcode = $hotelcode;
    
        return $this;
    }

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

    /**
     * Set languagecode
     *
     * @param string $languagecode
     * @return HotelDescriptions
     */
    public function setLanguagecode($languagecode)
    {
        $this->languagecode = $languagecode;
    
        return $this;
    }

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

    /**
     * Set hotelfacilities
     *
     * @param string $hotelfacilities
     * @return HotelDescriptions
     */
    public function setHotelfacilities($hotelfacilities)
    {
        $this->hotelfacilities = $hotelfacilities;
    
        return $this;
    }

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

    /**
     * Set hotellocationdescription
     *
     * @param string $hotellocationdescription
     * @return HotelDescriptions
     */
    public function setHotellocationdescription($hotellocationdescription)
    {
        $this->hotellocationdescription = $hotellocationdescription;
    
        return $this;
    }

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

    /**
     * Set hotelroomdescription
     *
     * @param string $hotelroomdescription
     * @return HotelDescriptions
     */
    public function setHotelroomdescription($hotelroomdescription)
    {
        $this->hotelroomdescription = $hotelroomdescription;
    
        return $this;
    }

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

    /**
     * Set holelsportdescription
     *
     * @param string $holelsportdescription
     * @return HotelDescriptions
     */
    public function setHolelsportdescription($holelsportdescription)
    {
        $this->holelsportdescription = $holelsportdescription;
    
        return $this;
    }

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

    /**
     * Set hotelmealsdescription
     *
     * @param string $hotelmealsdescription
     * @return HotelDescriptions
     */
    public function setHotelmealsdescription($hotelmealsdescription)
    {
        $this->hotelmealsdescription = $hotelmealsdescription;
    
        return $this;
    }

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

    /**
     * Set HotelPaymentMethods
     *
     * @param string $hotelPaymentMethods
     * @return HotelDescriptions
     */
    public function setHotelPaymentMethods($hotelPaymentMethods)
    {
        $this->HotelPaymentMethods = $hotelPaymentMethods;
    
        return $this;
    }

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

    /**
     * Set hotelhowtogetthere
     *
     * @param string $hotelhowtogetthere
     * @return HotelDescriptions
     */
    public function setHotelhowtogetthere($hotelhowtogetthere)
    {
        $this->hotelhowtogetthere = $hotelhowtogetthere;
    
        return $this;
    }

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

    /**
     * Set hotelcomments
     *
     * @param string $hotelcomments
     * @return HotelDescriptions
     */
    public function setHotelcomments($hotelcomments)
    {
        $this->hotelcomments = $hotelcomments;
    
        return $this;
    }

    /**
     * Get hotelcomments
     *
     * @return string 
     */
    public function getHotelcomments()
    {
        return $this->hotelcomments;
    }
}
asi lo tengo :S
  #13 (permalink)  
Antiguo 18/12/2012, 15:20
 
Fecha de Ingreso: abril-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Problemas con consulta symfony

Hola que tal mira nuevamente hice los cambios, lo genere con el comando mis entidades nuevamente, utilizando las relaciones "aunque no se ecuentren en la base de datos original que me dieron..." le cree todas las relaciones que se suponen deberian de estar "como me lo representaron en un documento que me dieron"... y tengo asi mis entidades:


Hotels:

Código:
<?
namespace cnt\HBBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use cnt\HBBundle\Entity\CategoryDescriptions;
use cnt\HBBundle\Entity\Zones;
use Symfony\Component\Validator\Constrainst as Assert;

/**
* @ORM\Entity(repositoryClass="cnt\HBBundle\Entity\HotelsRepository")
* @ORM\Table(name="HOTELS")
*/

class Hotels 
{
    /**
    * @ORM\Id 
    * @ORM\OneToMany(targetEntity="HOTEL_DESCRIPTIONS", mappedBy="HOTELS")
    * @ORM\OneToMany(targetEntity="CONTACTS", mappedBy="HOTELS")
    * @ORM\OneToMany(targetEntity="PHONES", mappedBy="HOTELS")
    * @ORM\OneToMany(targetEntity="HOTEL_IMAGES", mappedBy="HOTELS")
    * @ORM\Column(name="HOTELCODE",type="string", length=8, unique=true)
    */
    protected $hotelcode;
    
   /**
    * @ORM\Column(name="NAME",type="string", length=50)
    */
    protected $name;
 
    /**
    * @ORM\ManyToOne(targetEntity="CATEGORIES", inversedBy="HOTELS")
    * @ORM\Column(name="CATEGORYCODE",type="string", length=5)	
    */
    protected $categorycode;

   	/**
    * @ORM\Column(name="DESTINATIONCODE",type="string", length=3)
    */
    protected $destinationcode;
    
   /**
    * @ORM\ManyToOne(targetEntity="ZONES", inversedBy="HOTELS")
    * @ORM\Column(name="ZONECODE",type="string", length=8, nullable=true)
    */
    protected $zonecode = null;
 
    /**
    * @ORM\ManyToOne(targetEntity="CHAINS", inversedBy="HOTELS")
    * @ORM\Column(name="CHAINCODE",type="string", length=5, nullable=true)
    */
    protected $chaincode = null;
    
    /**
    * @ORM\Column(name="LICENCE",type="string", length=15, nullable=true)
    */
    protected $licence = null;

    /**
    * @ORM\Column(name="LATITUDE",type="string", length=45, nullable=true)
    */
    protected $latitude = null;

    /**
    * @ORM\Column(name="LONGITUDE",type="string", length=45, nullable=true)
    */
    protected $longitude = null;


    

    /**
     * Set hotelcode
     *
     * @param string $hotelcode
     * @return Hotels
     */
    public function setHotelcode($hotelcode)
    {
        $this->hotelcode = $hotelcode;
    
        return $this;
    }

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

    /**
     * Set name
     *
     * @param string $name
     * @return Hotels
     */
    public function setName($name)
    {
        $this->name = $name;
    
        return $this;
    }

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

    /**
     * Set categorycode
     *
     * @param string $categorycode
     * @return Hotels
     */
    public function setCategorycode($categorycode)
    {
        $this->categorycode = $categorycode;
    
        return $this;
    }

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

    /**
     * Set destinationcode
     *
     * @param string $destinationcode
     * @return Hotels
     */
    public function setDestinationcode($destinationcode)
    {
        $this->destinationcode = $destinationcode;
    
        return $this;
    }

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

    /**
     * Set zonecode
     *
     * @param string $zonecode
     * @return Hotels
     */
    public function setZonecode($zonecode)
    {
        $this->zonecode = $zonecode;
    
        return $this;
    }

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

    /**
     * Set chaincode
     *
     * @param string $chaincode
     * @return Hotels
     */
    public function setChaincode($chaincode)
    {
        $this->chaincode = $chaincode;
    
        return $this;
    }

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

    /**
     * Set licence
     *
     * @param string $licence
     * @return Hotels
     */
    public function setLicence($licence)
    {
        $this->licence = $licence;
    
        return $this;
    }

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

    /**
     * Set latitude
     *
     * @param string $latitude
     * @return Hotels
     */
    public function setLatitude($latitude)
    {
        $this->latitude = $latitude;
    
        return $this;
    }

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

    /**
     * Set longitude
     *
     * @param string $longitude
     * @return Hotels
     */
    public function setLongitude($longitude)
    {
        $this->longitude = $longitude;
    
        return $this;
    }

    /**
     * Get longitude
     *
     * @return string 
     */
    public function getLongitude()
    {
        return $this->longitude;
    }
}
HotelDescriptions:
  #14 (permalink)  
Antiguo 18/12/2012, 15:21
 
Fecha de Ingreso: abril-2012
Mensajes: 25
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Problemas con consulta symfony

Código:
<?
namespace cnt\HBBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use cnt\HBBundle\Entity\Lenguages;
use Symfony\Component\Validator\Constrainst as Assert;

/** 
* @ORM\Entity(repositoryClass="cnt\HBBundle\Entity\HotelDescriptionsRepository")
* @ORM\Table(name="HOTEL_DESCRIPTIONS")
*/

class HotelDescriptions
{ 
	/**
	* @ORM\Id
        * @ORM\ManyToOne(targetEntity="HOTELS", inversedBy="HOTEL_DESCRIPTIONS")
        * @ORM\Column(name="HotelCode",type="string", length=8, nullable=false, unique=true)
        */
	protected $hotelcode;
	
	/**
	* @ORM\Id
	* @ORM\ManyToOne(targetEntity="LANGUAGES", inversedBy="HOTEL_DESCRIPTIONS")
	* @ORM\Column(name="LanguageCode",type="string", length=3, nullable=false)
    */
	protected $languagecode;
	
	/**
	* @ORM\Column(name="HotelFacilities",type="string", length=2000, nullable=false)
    */
	protected $hotelfacilities;
	
	/**
	* @ORM\Column(name="HotelLocationDescription",type="string", length=2000, nullable=false)
    */
	protected $hotellocationdescription;
	
	/**
	* @ORM\Column(name="HotelRoomDescription",type="string", length=2000, nullable=false)
    */
	protected $hotelroomdescription;
	
	/**
	* @ORM\Column(name="HolelSportDescription",type="string", length=2000, nullable=false)
    */
	protected $holelsportdescription;
	
	/**
	* @ORM\Column(name="HotelMealsDescription",type="string", length=2000, nullable=false)
    */
	
        protected $hotelmealsdescription;
	
	/**
	* @ORM\Column(name="HotelPaymentMethods",type="string", length=2000, nullable=false)
    */
	protected $HotelPaymentMethods;
	
	/**
	* @ORM\Column(name="HotelHowToGetThere",type="string", length=2000, nullable=false)
        */
	protected $hotelhowtogetthere;
	
	/**
	* @ORM\Column(name="HotelComments",type="string", length=2000, nullable=false)
    */
	protected $hotelcomments;



    /**
     * Set hotelcode
     *
     * @param string $hotelcode
     * @return HotelDescriptions
     */
    public function setHotelcode($hotelcode)
    {
        $this->hotelcode = $hotelcode;
    
        return $this;
    }

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

    /**
     * Set languagecode
     *
     * @param string $languagecode
     * @return HotelDescriptions
     */
    public function setLanguagecode($languagecode)
    {
        $this->languagecode = $languagecode;
    
        return $this;
    }

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

    /**
     * Set hotelfacilities
     *
     * @param string $hotelfacilities
     * @return HotelDescriptions
     */
    public function setHotelfacilities($hotelfacilities)
    {
        $this->hotelfacilities = $hotelfacilities;
    
        return $this;
    }

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

    /**
     * Set hotellocationdescription
     *
     * @param string $hotellocationdescription
     * @return HotelDescriptions
     */
    public function setHotellocationdescription($hotellocationdescription)
    {
        $this->hotellocationdescription = $hotellocationdescription;
    
        return $this;
    }

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

    /**
     * Set hotelroomdescription
     *
     * @param string $hotelroomdescription
     * @return HotelDescriptions
     */
    public function setHotelroomdescription($hotelroomdescription)
    {
        $this->hotelroomdescription = $hotelroomdescription;
    
        return $this;
    }

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

    /**
     * Set holelsportdescription
     *
     * @param string $holelsportdescription
     * @return HotelDescriptions
     */
    public function setHolelsportdescription($holelsportdescription)
    {
        $this->holelsportdescription = $holelsportdescription;
    
        return $this;
    }

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

    /**
     * Set hotelmealsdescription
     *
     * @param string $hotelmealsdescription
     * @return HotelDescriptions
     */
    public function setHotelmealsdescription($hotelmealsdescription)
    {
        $this->hotelmealsdescription = $hotelmealsdescription;
    
        return $this;
    }

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

    /**
     * Set HotelPaymentMethods
     *
     * @param string $hotelPaymentMethods
     * @return HotelDescriptions
     */
    public function setHotelPaymentMethods($hotelPaymentMethods)
    {
        $this->HotelPaymentMethods = $hotelPaymentMethods;
    
        return $this;
    }

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

    /**
     * Set hotelhowtogetthere
     *
     * @param string $hotelhowtogetthere
     * @return HotelDescriptions
     */
    public function setHotelhowtogetthere($hotelhowtogetthere)
    {
        $this->hotelhowtogetthere = $hotelhowtogetthere;
    
        return $this;
    }

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

    /**
     * Set hotelcomments
     *
     * @param string $hotelcomments
     * @return HotelDescriptions
     */
    public function setHotelcomments($hotelcomments)
    {
        $this->hotelcomments = $hotelcomments;
    
        return $this;
    }

    /**
     * Get hotelcomments
     *
     * @return string 
     */
    public function getHotelcomments()
    {
        return $this->hotelcomments;
    }
}
y nuevamente inteto realizar mi dql, con la misma función:

Código:
 public function findByname($params){
			$name= $params['name'];
                        $language= $params['language'];
                        
                        $em = $this->getEntityManager();
			$query = $em->createQuery(' SELECT h, d
                                                    FROM cntHBBundle:Hotels h
                                                    JOIN h.HotelDescriptions d
                                                    WHERE h.hotelcode = :id
                                                    AND d.languagecode= :language
                                                     
                                                    ');
			$query->setParameter('id',$name);
                        $query->setParameter('language',$language);
			$query->setMaxResults(1);			
			$names = $query->getResult();
		return $names;
:S! y me sigue saliendo error:

[Semantical Error] line 0, col 168 near 'd': Error: Class cnt\HBBundle\Entity\Hotels has no association named HotelDescriptions

:(

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:53.