Doctrine get all elements from A that aren't in B












-1














Full Error



CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 170 near 'imagenes WHERE': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.") in "ROSHKABBVASitioExperienceBackendBundle:ExpPromociones:new.html.twig" at line 40." at C:xampphtdocsbbva-universosappcacheuniversos_devclasses.php line 4440 


I have two Queries to select all the elements of A that aren't in B, but I can't get to translate it to Doctrine



SELECT * 
FROM beneficiobbva.imagenes im
LEFT JOIN beneficiobbva.imagenes_x_exppromociones impro
ON im.id=impro.id_imagen
where impro.id_imagen is null;


OR



select *
from beneficiobbva.imagenes a
where a.id
NOT IN (
SELECT id_imagen
FROM beneficiobbva.imagenes_x_exppromociones
);


With doctrine I tried to do something like this but I get an error Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected."



This is my code:



    $imagenes = $em->createQueryBuilder()
->select('img')
->addSelect('img_pro')
->from('ROSHKABBVASitioUniversosImagenesBundle:Imagenes', 'img')
->leftjoin('ROSHKABBVASitioExperienceFrontendBundle:Exppromociones', 'img_pro', 'WITH', 'img.id=img_pro.imagenes')
->where('img_pro.imagenes is null')
->getQuery()
->getResult();


I have one entity which is Exppromociones.php
This is part of my entity, I think this is all you need because it's really long



    <?php

namespace ROSHKABBVASitioExperienceFrontendBundleEntity;

use DoctrineORMMapping as ORM;

/**
* Exppromociones
*/
class Exppromociones
{
/**
* @var integer
*/
private $id;

/**
* @var string
*/
private $nombre;

/**
* @var string
*/
private $descripcion;

/**
* @var integer
*/
private $puntos;

/**
* @var DateTime
*/
private $fechaInicio;

/**
* @var DateTime
*/
private $fechaFin;

/**
* @var boolean
*/
private $enPromocion;

/**
* @var string
*/
private $vigenciaDescripcion;

/**
* @var string
*/
private $miniDescripcion;

/**
* @var integer
*/
private $puntosOtros;

/**
* @var string
*/
private $flujoCanje;

/**
* @var ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias
*/
private $categoria;

/**
* @var ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
private $banner;

/**
* @var ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
private $imagen;

/**
* @var ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios
*/
private $comercio;

/**
* @var string
*
* @ORMColumn(name="Nombre_Real", type="text")
*/
private $nombreReal;

/**
* @var string
*
* @ORMColumn(name="Descripcion_Experience", type="text")
*/
private $descripcionExperience;

/**
* @var boolean
*/
private $destacado = false;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $imagenes;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $categorias;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $etiquetas;

/**
* @var DateTime
*/
private $fechaFinNovedad;

/**
* @var integer
*/
private $cantidadVista = 0;

/**
* @var integer
*/
private $cantidadCanjeada = 0;

/**
* @var integer
*/
private $valorGuaranies = 0;

/**
* @var integer
*/
private $puntosTelefonico;

/**
* @var string
*/
private $texto_circulo;

/**
* @var boolean
*/
private $mostrarValorGuaranies;


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

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

return $this;
}

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

/**
* Set descripcion
*
* @param string $descripcion
* @return Exppromociones
*/
public function setDescripcion($descripcion)
{
$this->descripcion = $descripcion;

return $this;
}

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

/**
* Set puntos
*
* @param integer $puntos
* @return Exppromociones
*/
public function setPuntos($puntos)
{
$this->puntos = $puntos;

return $this;
}

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

/**
* Set fechaInicio
*
* @param DateTime $fechaInicio
* @return Exppromociones
*/
public function setFechaInicio($fechaInicio)
{
$this->fechaInicio = $fechaInicio;

return $this;
}

/**
* Get fechaInicio
*
* @return DateTime
*/
public function getFechaInicio()
{
return $this->fechaInicio;
}

/**
* Set fechaFin
*
* @param DateTime $fechaFin
* @return Exppromociones
*/
public function setFechaFin($fechaFin)
{
$this->fechaFin = $fechaFin;

return $this;
}

/**
* Get fechaFin
*
* @return DateTime
*/
public function getFechaFin()
{
return $this->fechaFin;
}

/**
* Set enPromocion
*
* @param boolean $enPromocion
* @return Exppromociones
*/
public function setEnPromocion($enPromocion)
{
$this->enPromocion = $enPromocion;

return $this;
}

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

/**
* Set vigenciaDescripcion
*
* @param string $vigenciaDescripcion
* @return Exppromociones
*/
public function setVigenciaDescripcion($vigenciaDescripcion)
{
$this->vigenciaDescripcion = $vigenciaDescripcion;

return $this;
}

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

/**
* Set miniDescripcion
*
* @param string $miniDescripcion
* @return Exppromociones
*/
public function setMiniDescripcion($miniDescripcion)
{
$this->miniDescripcion = $miniDescripcion;

return $this;
}

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

/**
* Set puntosOtros
*
* @param integer $puntosOtros
* @return Exppromociones
*/
public function setPuntosOtros($puntosOtros)
{
$this->puntosOtros = $puntosOtros;

return $this;
}

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

/**
* Set flujoCanje
*
* @param string $flujoCanje
* @return Exppromociones
*/
public function setFlujoCanje($flujoCanje)
{
$this->flujoCanje = $flujoCanje;

return $this;
}

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

/**
* Set categoria
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias $categoria
* @return Exppromociones
*/
public function setCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias $categoria = null)
{
$this->categoria = $categoria;

return $this;
}

/**
* Get categoria
*
* @return ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias
*/
public function getCategoria()
{
return $this->categoria;
}

/**
* Set banner
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $banner
* @return Exppromociones
*/
public function setBanner(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $banner = null)
{
$this->banner = $banner;

return $this;
}

/**
* Get banner
*
* @return ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
public function getBanner()
{
return $this->banner;
}

/**
* Set imagen
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagen
* @return Exppromociones
*/
public function setImagen(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagen = null)
{
$this->imagen = $imagen;

return $this;
}

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

/**
* Set comercio
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios $comercio
* @return Exppromociones
*/
public function setComercio(ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios $comercio = null)
{
$this->comercio = $comercio;

return $this;
}

/**
* Get comercio
*
* @return ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios
*/
public function getComercio()
{
return $this->comercio;
}

/**
* Set nombreReal
*
* @param string $nombreReal
* @return ExpPromociones
*/
public function setNombreReal($nombreReal)
{
$this->nombreReal = $nombreReal;

return $this;
}

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

/**
* Set descripcionExperience
*
* @param string $descripcionExperience
* @return ExpPromociones
*/
public function setDescripcionExperience($descripcionExperience)
{
$this->descripcionExperience = $descripcionExperience;

return $this;
}

/**
* Get descripcionExperience
*
* @return string
*/
public function getDescripcionExperience()
{
return $this->descripcionExperience;
}
/**
* @var integer
*/
private $orden = 0;


/**
* Set orden
*
* @param integer $orden
* @return Exppromociones
*/
public function setOrden($orden)
{
$this->orden = $orden;

return $this;
}

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

/**
* Determina si la promoción es un viaje genérico,
* según las condición:
* - $flujoCanje de la instancia debe ser igual al string 'generico', y
* - Id de la categoría asociada debe ser igual a 2 (Viajes)
*
* "Opción Genérico": Es una promoción canjeable de tipo Viaje,
* en la que el usuario puede determinar cuántos puntos utilizar.
*
* @return boolean
*/
public function esOpcionGenerica()
{
$categorias = $this->getCategorias();
$flujoCanje = $this->getFlujoCanje();
$esViaje=false;
foreach($categorias as $categoria){
if($categoria->getId() == 2){
$esViaje = true;
break;
}
}
// Comparar cadenas.
// "strcasecmp: Binary safe case-insensitive string comparison".
// retorna 0 si las cadenas son iguales, ignorando mayusculas.
$esGenerico = strcasecmp($flujoCanje, 'generico') == 0;

return $esViaje && $esGenerico;

}

/**
* Determina si la promoción es un viaje
* según las condición:
* - Id de la categoría asociada debe ser igual a 2 (Viajes)
*
* @return boolean
*/
public function esViaje()
{
$categorias = $this->getCategorias();
$esViaje=false;
foreach($categorias as $categoria){
if($categoria->getId() == 2){
$esViaje = true;
break;
}
}

return $esViaje;

}

/**
* Constructor
*/
public function __construct()
{
$this->imagenes = new DoctrineCommonCollectionsArrayCollection();
$this->categorias = new DoctrineCommonCollectionsArrayCollection();
$this->etiquetas = new DoctrineCommonCollectionsArrayCollection();
}

/**
* Get imagenes
*
* @return DoctrineCommonCollectionsCollection
*/
public function getImagenes()
{
return $this->imagenes;
}

/**
* Set destacado
*
* @param boolean $destacado
* @return Exppromociones
*/
public function setDestacado($destacado)
{
$this->destacado = $destacado;

return $this;
}

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

/**
* Add categorias
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias
* @return Exppromociones
*/
public function addCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias)
{
$this->categorias = $categorias;

return $this;
}

/**
* Remove categorias
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias
*/
public function removeCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias)
{
$this->categorias->removeElement($categorias);
}

/**
* Get categorias
*
* @return DoctrineCommonCollectionsCollection
*/
public function getCategorias()
{
return $this->categorias;
}


/**
* Add imagenes
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes
* @return Exppromociones
*/
public function addImagene(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes)
{
$this->imagenes = $imagenes;

return $this;
}

/**
* Remove imagenes
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes
*/
public function removeImagene(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes)
{
$this->imagenes->removeElement($imagenes);
}

/**
* Add etiquetas
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas
* @return Exppromociones
*/
public function addEtiqueta(ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas)
{
$this->etiquetas = $etiquetas;

return $this;
}

/**
* Remove etiquetas
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas
*/
public function removeEtiqueta(ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas)
{
$this->etiquetas->removeElement($etiquetas);
}

/**
* Get etiquetas
*
* @return DoctrineCommonCollectionsCollection
*/
public function getEtiquetas()
{
return $this->etiquetas;
}

/**
* Set fechaFinNovedad
*
* @param DateTime $fechaFinNovedad
* @return Exppromociones
*/
public function setFechaFinNovedad($fechaFinNovedad)
{
$this->fechaFinNovedad = $fechaFinNovedad;

return $this;
}

/**
* Get fechaFinNovedad
*
* @return DateTime
*/
public function getFechaFinNovedad()
{
return $this->fechaFinNovedad;
}

/**
* Set cantidadVista
*
* @param integer $cantidadVista
* @return Exppromociones
*/
public function setCantidadVista($cantidadVista)
{
$this->cantidadVista = $cantidadVista;

return $this;
}

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

/**
* Set cantidadCanjeada
*
* @param integer $cantidadCanjeada
* @return Exppromociones
*/
public function setCantidadCanjeada($cantidadCanjeada)
{
$this->cantidadCanjeada = $cantidadCanjeada;

return $this;
}

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

/**
* Set valorGuaranies
*
* @param integer $valorGuaranies
* @return Exppromociones
*/
public function setValorGuaranies($valorGuaranies)
{
$this->valorGuaranies = $valorGuaranies;

return $this;
}

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

/**
* Set puntosTelefonico
*
* @param integer $puntosTelefonico
* @return Exppromociones
*/
public function setPuntosTelefonico($puntosTelefonico)
{
$this->puntosTelefonico = $puntosTelefonico;

return $this;
}

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

/**
* Set texto_circulo
*
* @param string $textoCirculo
* @return Exppromociones
*/
public function setTextoCirculo($textoCirculo)
{
$this->texto_circulo = $textoCirculo;

return $this;
}

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

public function __toString()
{
return $this->getNombre();
}

/**
* Set mostrarValorGuaranies
*
* @param boolean $mostrarValorGuaranies
* @return Exppromociones
*/
public function setMostrarValorGuaranies($mostrarValorGuaranies)
{
$this->mostrarValorGuaranies = $mostrarValorGuaranies;

return $this;
}

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


This entity Exppromociones has an attribute $imagenes, which has instances of another entity Imagenes
Imagenes.php



<?php

namespace ROSHKABBVASitioUniversosImagenesBundleEntity;

use IphpFileStoreBundleMappingAnnotation as FileStore;
use SymfonyComponentValidatorConstraints as Assert;
use DoctrineORMMapping as ORM;

/**
* Imagenes
*
* @ORMTable(name="imagenes")
* @ORMEntity
* @FileStoreUploadable
*/
class Imagenes
{
/**
* @var integer
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @var string
*
* @ORMColumn(name="Nombre", type="string", length=255)
*/
private $nombre;


/**
* @var Datetime
*
* @ORMColumn(name="Fecha_Carga", type="date")
*/
private $fechaCarga;

/**
* @ORMColumn(name="Enlace", type="array")
* @AssertFile( maxSize="20M")
* @FileStoreUploadableField(mapping="imagenes")
**/
private $enlace;

/**
* @var string
*
* @ORMColumn(name="Tipo", type="string", length=255)
*/
private $tipo;

/**
* @var string
*
* @ORMColumn(name="Link", type="string", length=255)
*/
private $link;


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

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

return $this;
}

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

/**
* Set fechaCarga
*
* @param DateTime $fechaCarga
* @return Imagenes
*/
public function setFechaCarga($fechaCarga)
{
$this->fechaCarga = $fechaCarga;

return $this;
}

/**
* Get fechaCarga
*
* @return DateTime
*/
public function getFechaCarga()
{
return $this->fechaCarga;
}

/**
* Set enlace
*
* @param array $enlace
* @return Imagenes
*/
public function setEnlace($enlace)
{
$this->enlace = $enlace;

return $this;
}

/**
* Get enlace
*
* @return array
*/
public function getEnlace()
{
return $this->enlace;
}

public function __toString()
{
return $this->getNombre();
}

/**
* Set tipo
*
* @param string $tipo
* @return Imagenes
*/
public function setTipo($tipo)
{
$this->tipo = $tipo;

return $this;
}

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

/**
* Set link
*
* @param string $link
* @return Imagenes
*/
public function setLink($link)
{
$this->link = $link;

return $this;
}

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

public function __construct(){
$this->fechaCarga = new DateTime();
}
}


I want to see al the images from Imagenes that aren't associated to Exppromociones



mapping:



ROSHKABBVASitioExperienceFrontendBundleEntityExppromociones:
type: entity
table: exppromociones
indexes:
IDX_4EE4A008763C8AA7:
columns:
- imagen_id
IDX_4EE4A008684EC833:
columns:
- banner_id
IDX_4EE4A0083397707A:
columns:
- categoria_id
IDX_COMERCIOS_PROMOCION:
columns:
- comercio_id
id:
id:
type: integer
nullable: false
unsigned: false
comment: ''
id: true
generator:
strategy: IDENTITY
fields:
...
...
manyToMany:
imagenes:
cascade: ["persist","remove"]
targetEntity: ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
joinTable:
name: imagenes_x_exppromociones
joinColumns:
id_promocion:
referencedColumnName: id
inverseJoinColumns:
id_imagen:
referencedColumnName: id
unique: true
lifecycleCallbacks: { }









share|improve this question
























  • Could you try >where('img_pro is null')
    – Ahmed bhs
    Nov 12 at 15:13










  • Not working, I get an error before that line in 'img.id=img_pro.image_id', i think it says image_id has multiple values and is expecting a singlevaluedassociationfield.
    – Xav
    Nov 12 at 15:19










  • With Doctrine, you're able to use native SQL queries. You can find more information here: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/… There's no need to translate all the query to Doctrine, and with the native query you're going to have a better performance.
    – J. Almandos
    Nov 12 at 15:20












  • Also, you can use DQL that is pretty similar to SQL: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/…
    – J. Almandos
    Nov 12 at 15:23










  • Thanks! I'll take a look at those links
    – Xav
    Nov 12 at 15:27
















-1














Full Error



CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 170 near 'imagenes WHERE': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.") in "ROSHKABBVASitioExperienceBackendBundle:ExpPromociones:new.html.twig" at line 40." at C:xampphtdocsbbva-universosappcacheuniversos_devclasses.php line 4440 


I have two Queries to select all the elements of A that aren't in B, but I can't get to translate it to Doctrine



SELECT * 
FROM beneficiobbva.imagenes im
LEFT JOIN beneficiobbva.imagenes_x_exppromociones impro
ON im.id=impro.id_imagen
where impro.id_imagen is null;


OR



select *
from beneficiobbva.imagenes a
where a.id
NOT IN (
SELECT id_imagen
FROM beneficiobbva.imagenes_x_exppromociones
);


With doctrine I tried to do something like this but I get an error Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected."



This is my code:



    $imagenes = $em->createQueryBuilder()
->select('img')
->addSelect('img_pro')
->from('ROSHKABBVASitioUniversosImagenesBundle:Imagenes', 'img')
->leftjoin('ROSHKABBVASitioExperienceFrontendBundle:Exppromociones', 'img_pro', 'WITH', 'img.id=img_pro.imagenes')
->where('img_pro.imagenes is null')
->getQuery()
->getResult();


I have one entity which is Exppromociones.php
This is part of my entity, I think this is all you need because it's really long



    <?php

namespace ROSHKABBVASitioExperienceFrontendBundleEntity;

use DoctrineORMMapping as ORM;

/**
* Exppromociones
*/
class Exppromociones
{
/**
* @var integer
*/
private $id;

/**
* @var string
*/
private $nombre;

/**
* @var string
*/
private $descripcion;

/**
* @var integer
*/
private $puntos;

/**
* @var DateTime
*/
private $fechaInicio;

/**
* @var DateTime
*/
private $fechaFin;

/**
* @var boolean
*/
private $enPromocion;

/**
* @var string
*/
private $vigenciaDescripcion;

/**
* @var string
*/
private $miniDescripcion;

/**
* @var integer
*/
private $puntosOtros;

/**
* @var string
*/
private $flujoCanje;

/**
* @var ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias
*/
private $categoria;

/**
* @var ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
private $banner;

/**
* @var ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
private $imagen;

/**
* @var ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios
*/
private $comercio;

/**
* @var string
*
* @ORMColumn(name="Nombre_Real", type="text")
*/
private $nombreReal;

/**
* @var string
*
* @ORMColumn(name="Descripcion_Experience", type="text")
*/
private $descripcionExperience;

/**
* @var boolean
*/
private $destacado = false;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $imagenes;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $categorias;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $etiquetas;

/**
* @var DateTime
*/
private $fechaFinNovedad;

/**
* @var integer
*/
private $cantidadVista = 0;

/**
* @var integer
*/
private $cantidadCanjeada = 0;

/**
* @var integer
*/
private $valorGuaranies = 0;

/**
* @var integer
*/
private $puntosTelefonico;

/**
* @var string
*/
private $texto_circulo;

/**
* @var boolean
*/
private $mostrarValorGuaranies;


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

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

return $this;
}

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

/**
* Set descripcion
*
* @param string $descripcion
* @return Exppromociones
*/
public function setDescripcion($descripcion)
{
$this->descripcion = $descripcion;

return $this;
}

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

/**
* Set puntos
*
* @param integer $puntos
* @return Exppromociones
*/
public function setPuntos($puntos)
{
$this->puntos = $puntos;

return $this;
}

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

/**
* Set fechaInicio
*
* @param DateTime $fechaInicio
* @return Exppromociones
*/
public function setFechaInicio($fechaInicio)
{
$this->fechaInicio = $fechaInicio;

return $this;
}

/**
* Get fechaInicio
*
* @return DateTime
*/
public function getFechaInicio()
{
return $this->fechaInicio;
}

/**
* Set fechaFin
*
* @param DateTime $fechaFin
* @return Exppromociones
*/
public function setFechaFin($fechaFin)
{
$this->fechaFin = $fechaFin;

return $this;
}

/**
* Get fechaFin
*
* @return DateTime
*/
public function getFechaFin()
{
return $this->fechaFin;
}

/**
* Set enPromocion
*
* @param boolean $enPromocion
* @return Exppromociones
*/
public function setEnPromocion($enPromocion)
{
$this->enPromocion = $enPromocion;

return $this;
}

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

/**
* Set vigenciaDescripcion
*
* @param string $vigenciaDescripcion
* @return Exppromociones
*/
public function setVigenciaDescripcion($vigenciaDescripcion)
{
$this->vigenciaDescripcion = $vigenciaDescripcion;

return $this;
}

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

/**
* Set miniDescripcion
*
* @param string $miniDescripcion
* @return Exppromociones
*/
public function setMiniDescripcion($miniDescripcion)
{
$this->miniDescripcion = $miniDescripcion;

return $this;
}

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

/**
* Set puntosOtros
*
* @param integer $puntosOtros
* @return Exppromociones
*/
public function setPuntosOtros($puntosOtros)
{
$this->puntosOtros = $puntosOtros;

return $this;
}

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

/**
* Set flujoCanje
*
* @param string $flujoCanje
* @return Exppromociones
*/
public function setFlujoCanje($flujoCanje)
{
$this->flujoCanje = $flujoCanje;

return $this;
}

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

/**
* Set categoria
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias $categoria
* @return Exppromociones
*/
public function setCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias $categoria = null)
{
$this->categoria = $categoria;

return $this;
}

/**
* Get categoria
*
* @return ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias
*/
public function getCategoria()
{
return $this->categoria;
}

/**
* Set banner
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $banner
* @return Exppromociones
*/
public function setBanner(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $banner = null)
{
$this->banner = $banner;

return $this;
}

/**
* Get banner
*
* @return ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
public function getBanner()
{
return $this->banner;
}

/**
* Set imagen
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagen
* @return Exppromociones
*/
public function setImagen(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagen = null)
{
$this->imagen = $imagen;

return $this;
}

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

/**
* Set comercio
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios $comercio
* @return Exppromociones
*/
public function setComercio(ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios $comercio = null)
{
$this->comercio = $comercio;

return $this;
}

/**
* Get comercio
*
* @return ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios
*/
public function getComercio()
{
return $this->comercio;
}

/**
* Set nombreReal
*
* @param string $nombreReal
* @return ExpPromociones
*/
public function setNombreReal($nombreReal)
{
$this->nombreReal = $nombreReal;

return $this;
}

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

/**
* Set descripcionExperience
*
* @param string $descripcionExperience
* @return ExpPromociones
*/
public function setDescripcionExperience($descripcionExperience)
{
$this->descripcionExperience = $descripcionExperience;

return $this;
}

/**
* Get descripcionExperience
*
* @return string
*/
public function getDescripcionExperience()
{
return $this->descripcionExperience;
}
/**
* @var integer
*/
private $orden = 0;


/**
* Set orden
*
* @param integer $orden
* @return Exppromociones
*/
public function setOrden($orden)
{
$this->orden = $orden;

return $this;
}

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

/**
* Determina si la promoción es un viaje genérico,
* según las condición:
* - $flujoCanje de la instancia debe ser igual al string 'generico', y
* - Id de la categoría asociada debe ser igual a 2 (Viajes)
*
* "Opción Genérico": Es una promoción canjeable de tipo Viaje,
* en la que el usuario puede determinar cuántos puntos utilizar.
*
* @return boolean
*/
public function esOpcionGenerica()
{
$categorias = $this->getCategorias();
$flujoCanje = $this->getFlujoCanje();
$esViaje=false;
foreach($categorias as $categoria){
if($categoria->getId() == 2){
$esViaje = true;
break;
}
}
// Comparar cadenas.
// "strcasecmp: Binary safe case-insensitive string comparison".
// retorna 0 si las cadenas son iguales, ignorando mayusculas.
$esGenerico = strcasecmp($flujoCanje, 'generico') == 0;

return $esViaje && $esGenerico;

}

/**
* Determina si la promoción es un viaje
* según las condición:
* - Id de la categoría asociada debe ser igual a 2 (Viajes)
*
* @return boolean
*/
public function esViaje()
{
$categorias = $this->getCategorias();
$esViaje=false;
foreach($categorias as $categoria){
if($categoria->getId() == 2){
$esViaje = true;
break;
}
}

return $esViaje;

}

/**
* Constructor
*/
public function __construct()
{
$this->imagenes = new DoctrineCommonCollectionsArrayCollection();
$this->categorias = new DoctrineCommonCollectionsArrayCollection();
$this->etiquetas = new DoctrineCommonCollectionsArrayCollection();
}

/**
* Get imagenes
*
* @return DoctrineCommonCollectionsCollection
*/
public function getImagenes()
{
return $this->imagenes;
}

/**
* Set destacado
*
* @param boolean $destacado
* @return Exppromociones
*/
public function setDestacado($destacado)
{
$this->destacado = $destacado;

return $this;
}

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

/**
* Add categorias
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias
* @return Exppromociones
*/
public function addCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias)
{
$this->categorias = $categorias;

return $this;
}

/**
* Remove categorias
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias
*/
public function removeCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias)
{
$this->categorias->removeElement($categorias);
}

/**
* Get categorias
*
* @return DoctrineCommonCollectionsCollection
*/
public function getCategorias()
{
return $this->categorias;
}


/**
* Add imagenes
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes
* @return Exppromociones
*/
public function addImagene(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes)
{
$this->imagenes = $imagenes;

return $this;
}

/**
* Remove imagenes
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes
*/
public function removeImagene(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes)
{
$this->imagenes->removeElement($imagenes);
}

/**
* Add etiquetas
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas
* @return Exppromociones
*/
public function addEtiqueta(ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas)
{
$this->etiquetas = $etiquetas;

return $this;
}

/**
* Remove etiquetas
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas
*/
public function removeEtiqueta(ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas)
{
$this->etiquetas->removeElement($etiquetas);
}

/**
* Get etiquetas
*
* @return DoctrineCommonCollectionsCollection
*/
public function getEtiquetas()
{
return $this->etiquetas;
}

/**
* Set fechaFinNovedad
*
* @param DateTime $fechaFinNovedad
* @return Exppromociones
*/
public function setFechaFinNovedad($fechaFinNovedad)
{
$this->fechaFinNovedad = $fechaFinNovedad;

return $this;
}

/**
* Get fechaFinNovedad
*
* @return DateTime
*/
public function getFechaFinNovedad()
{
return $this->fechaFinNovedad;
}

/**
* Set cantidadVista
*
* @param integer $cantidadVista
* @return Exppromociones
*/
public function setCantidadVista($cantidadVista)
{
$this->cantidadVista = $cantidadVista;

return $this;
}

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

/**
* Set cantidadCanjeada
*
* @param integer $cantidadCanjeada
* @return Exppromociones
*/
public function setCantidadCanjeada($cantidadCanjeada)
{
$this->cantidadCanjeada = $cantidadCanjeada;

return $this;
}

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

/**
* Set valorGuaranies
*
* @param integer $valorGuaranies
* @return Exppromociones
*/
public function setValorGuaranies($valorGuaranies)
{
$this->valorGuaranies = $valorGuaranies;

return $this;
}

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

/**
* Set puntosTelefonico
*
* @param integer $puntosTelefonico
* @return Exppromociones
*/
public function setPuntosTelefonico($puntosTelefonico)
{
$this->puntosTelefonico = $puntosTelefonico;

return $this;
}

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

/**
* Set texto_circulo
*
* @param string $textoCirculo
* @return Exppromociones
*/
public function setTextoCirculo($textoCirculo)
{
$this->texto_circulo = $textoCirculo;

return $this;
}

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

public function __toString()
{
return $this->getNombre();
}

/**
* Set mostrarValorGuaranies
*
* @param boolean $mostrarValorGuaranies
* @return Exppromociones
*/
public function setMostrarValorGuaranies($mostrarValorGuaranies)
{
$this->mostrarValorGuaranies = $mostrarValorGuaranies;

return $this;
}

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


This entity Exppromociones has an attribute $imagenes, which has instances of another entity Imagenes
Imagenes.php



<?php

namespace ROSHKABBVASitioUniversosImagenesBundleEntity;

use IphpFileStoreBundleMappingAnnotation as FileStore;
use SymfonyComponentValidatorConstraints as Assert;
use DoctrineORMMapping as ORM;

/**
* Imagenes
*
* @ORMTable(name="imagenes")
* @ORMEntity
* @FileStoreUploadable
*/
class Imagenes
{
/**
* @var integer
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @var string
*
* @ORMColumn(name="Nombre", type="string", length=255)
*/
private $nombre;


/**
* @var Datetime
*
* @ORMColumn(name="Fecha_Carga", type="date")
*/
private $fechaCarga;

/**
* @ORMColumn(name="Enlace", type="array")
* @AssertFile( maxSize="20M")
* @FileStoreUploadableField(mapping="imagenes")
**/
private $enlace;

/**
* @var string
*
* @ORMColumn(name="Tipo", type="string", length=255)
*/
private $tipo;

/**
* @var string
*
* @ORMColumn(name="Link", type="string", length=255)
*/
private $link;


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

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

return $this;
}

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

/**
* Set fechaCarga
*
* @param DateTime $fechaCarga
* @return Imagenes
*/
public function setFechaCarga($fechaCarga)
{
$this->fechaCarga = $fechaCarga;

return $this;
}

/**
* Get fechaCarga
*
* @return DateTime
*/
public function getFechaCarga()
{
return $this->fechaCarga;
}

/**
* Set enlace
*
* @param array $enlace
* @return Imagenes
*/
public function setEnlace($enlace)
{
$this->enlace = $enlace;

return $this;
}

/**
* Get enlace
*
* @return array
*/
public function getEnlace()
{
return $this->enlace;
}

public function __toString()
{
return $this->getNombre();
}

/**
* Set tipo
*
* @param string $tipo
* @return Imagenes
*/
public function setTipo($tipo)
{
$this->tipo = $tipo;

return $this;
}

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

/**
* Set link
*
* @param string $link
* @return Imagenes
*/
public function setLink($link)
{
$this->link = $link;

return $this;
}

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

public function __construct(){
$this->fechaCarga = new DateTime();
}
}


I want to see al the images from Imagenes that aren't associated to Exppromociones



mapping:



ROSHKABBVASitioExperienceFrontendBundleEntityExppromociones:
type: entity
table: exppromociones
indexes:
IDX_4EE4A008763C8AA7:
columns:
- imagen_id
IDX_4EE4A008684EC833:
columns:
- banner_id
IDX_4EE4A0083397707A:
columns:
- categoria_id
IDX_COMERCIOS_PROMOCION:
columns:
- comercio_id
id:
id:
type: integer
nullable: false
unsigned: false
comment: ''
id: true
generator:
strategy: IDENTITY
fields:
...
...
manyToMany:
imagenes:
cascade: ["persist","remove"]
targetEntity: ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
joinTable:
name: imagenes_x_exppromociones
joinColumns:
id_promocion:
referencedColumnName: id
inverseJoinColumns:
id_imagen:
referencedColumnName: id
unique: true
lifecycleCallbacks: { }









share|improve this question
























  • Could you try >where('img_pro is null')
    – Ahmed bhs
    Nov 12 at 15:13










  • Not working, I get an error before that line in 'img.id=img_pro.image_id', i think it says image_id has multiple values and is expecting a singlevaluedassociationfield.
    – Xav
    Nov 12 at 15:19










  • With Doctrine, you're able to use native SQL queries. You can find more information here: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/… There's no need to translate all the query to Doctrine, and with the native query you're going to have a better performance.
    – J. Almandos
    Nov 12 at 15:20












  • Also, you can use DQL that is pretty similar to SQL: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/…
    – J. Almandos
    Nov 12 at 15:23










  • Thanks! I'll take a look at those links
    – Xav
    Nov 12 at 15:27














-1












-1








-1







Full Error



CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 170 near 'imagenes WHERE': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.") in "ROSHKABBVASitioExperienceBackendBundle:ExpPromociones:new.html.twig" at line 40." at C:xampphtdocsbbva-universosappcacheuniversos_devclasses.php line 4440 


I have two Queries to select all the elements of A that aren't in B, but I can't get to translate it to Doctrine



SELECT * 
FROM beneficiobbva.imagenes im
LEFT JOIN beneficiobbva.imagenes_x_exppromociones impro
ON im.id=impro.id_imagen
where impro.id_imagen is null;


OR



select *
from beneficiobbva.imagenes a
where a.id
NOT IN (
SELECT id_imagen
FROM beneficiobbva.imagenes_x_exppromociones
);


With doctrine I tried to do something like this but I get an error Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected."



This is my code:



    $imagenes = $em->createQueryBuilder()
->select('img')
->addSelect('img_pro')
->from('ROSHKABBVASitioUniversosImagenesBundle:Imagenes', 'img')
->leftjoin('ROSHKABBVASitioExperienceFrontendBundle:Exppromociones', 'img_pro', 'WITH', 'img.id=img_pro.imagenes')
->where('img_pro.imagenes is null')
->getQuery()
->getResult();


I have one entity which is Exppromociones.php
This is part of my entity, I think this is all you need because it's really long



    <?php

namespace ROSHKABBVASitioExperienceFrontendBundleEntity;

use DoctrineORMMapping as ORM;

/**
* Exppromociones
*/
class Exppromociones
{
/**
* @var integer
*/
private $id;

/**
* @var string
*/
private $nombre;

/**
* @var string
*/
private $descripcion;

/**
* @var integer
*/
private $puntos;

/**
* @var DateTime
*/
private $fechaInicio;

/**
* @var DateTime
*/
private $fechaFin;

/**
* @var boolean
*/
private $enPromocion;

/**
* @var string
*/
private $vigenciaDescripcion;

/**
* @var string
*/
private $miniDescripcion;

/**
* @var integer
*/
private $puntosOtros;

/**
* @var string
*/
private $flujoCanje;

/**
* @var ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias
*/
private $categoria;

/**
* @var ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
private $banner;

/**
* @var ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
private $imagen;

/**
* @var ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios
*/
private $comercio;

/**
* @var string
*
* @ORMColumn(name="Nombre_Real", type="text")
*/
private $nombreReal;

/**
* @var string
*
* @ORMColumn(name="Descripcion_Experience", type="text")
*/
private $descripcionExperience;

/**
* @var boolean
*/
private $destacado = false;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $imagenes;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $categorias;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $etiquetas;

/**
* @var DateTime
*/
private $fechaFinNovedad;

/**
* @var integer
*/
private $cantidadVista = 0;

/**
* @var integer
*/
private $cantidadCanjeada = 0;

/**
* @var integer
*/
private $valorGuaranies = 0;

/**
* @var integer
*/
private $puntosTelefonico;

/**
* @var string
*/
private $texto_circulo;

/**
* @var boolean
*/
private $mostrarValorGuaranies;


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

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

return $this;
}

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

/**
* Set descripcion
*
* @param string $descripcion
* @return Exppromociones
*/
public function setDescripcion($descripcion)
{
$this->descripcion = $descripcion;

return $this;
}

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

/**
* Set puntos
*
* @param integer $puntos
* @return Exppromociones
*/
public function setPuntos($puntos)
{
$this->puntos = $puntos;

return $this;
}

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

/**
* Set fechaInicio
*
* @param DateTime $fechaInicio
* @return Exppromociones
*/
public function setFechaInicio($fechaInicio)
{
$this->fechaInicio = $fechaInicio;

return $this;
}

/**
* Get fechaInicio
*
* @return DateTime
*/
public function getFechaInicio()
{
return $this->fechaInicio;
}

/**
* Set fechaFin
*
* @param DateTime $fechaFin
* @return Exppromociones
*/
public function setFechaFin($fechaFin)
{
$this->fechaFin = $fechaFin;

return $this;
}

/**
* Get fechaFin
*
* @return DateTime
*/
public function getFechaFin()
{
return $this->fechaFin;
}

/**
* Set enPromocion
*
* @param boolean $enPromocion
* @return Exppromociones
*/
public function setEnPromocion($enPromocion)
{
$this->enPromocion = $enPromocion;

return $this;
}

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

/**
* Set vigenciaDescripcion
*
* @param string $vigenciaDescripcion
* @return Exppromociones
*/
public function setVigenciaDescripcion($vigenciaDescripcion)
{
$this->vigenciaDescripcion = $vigenciaDescripcion;

return $this;
}

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

/**
* Set miniDescripcion
*
* @param string $miniDescripcion
* @return Exppromociones
*/
public function setMiniDescripcion($miniDescripcion)
{
$this->miniDescripcion = $miniDescripcion;

return $this;
}

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

/**
* Set puntosOtros
*
* @param integer $puntosOtros
* @return Exppromociones
*/
public function setPuntosOtros($puntosOtros)
{
$this->puntosOtros = $puntosOtros;

return $this;
}

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

/**
* Set flujoCanje
*
* @param string $flujoCanje
* @return Exppromociones
*/
public function setFlujoCanje($flujoCanje)
{
$this->flujoCanje = $flujoCanje;

return $this;
}

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

/**
* Set categoria
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias $categoria
* @return Exppromociones
*/
public function setCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias $categoria = null)
{
$this->categoria = $categoria;

return $this;
}

/**
* Get categoria
*
* @return ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias
*/
public function getCategoria()
{
return $this->categoria;
}

/**
* Set banner
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $banner
* @return Exppromociones
*/
public function setBanner(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $banner = null)
{
$this->banner = $banner;

return $this;
}

/**
* Get banner
*
* @return ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
public function getBanner()
{
return $this->banner;
}

/**
* Set imagen
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagen
* @return Exppromociones
*/
public function setImagen(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagen = null)
{
$this->imagen = $imagen;

return $this;
}

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

/**
* Set comercio
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios $comercio
* @return Exppromociones
*/
public function setComercio(ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios $comercio = null)
{
$this->comercio = $comercio;

return $this;
}

/**
* Get comercio
*
* @return ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios
*/
public function getComercio()
{
return $this->comercio;
}

/**
* Set nombreReal
*
* @param string $nombreReal
* @return ExpPromociones
*/
public function setNombreReal($nombreReal)
{
$this->nombreReal = $nombreReal;

return $this;
}

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

/**
* Set descripcionExperience
*
* @param string $descripcionExperience
* @return ExpPromociones
*/
public function setDescripcionExperience($descripcionExperience)
{
$this->descripcionExperience = $descripcionExperience;

return $this;
}

/**
* Get descripcionExperience
*
* @return string
*/
public function getDescripcionExperience()
{
return $this->descripcionExperience;
}
/**
* @var integer
*/
private $orden = 0;


/**
* Set orden
*
* @param integer $orden
* @return Exppromociones
*/
public function setOrden($orden)
{
$this->orden = $orden;

return $this;
}

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

/**
* Determina si la promoción es un viaje genérico,
* según las condición:
* - $flujoCanje de la instancia debe ser igual al string 'generico', y
* - Id de la categoría asociada debe ser igual a 2 (Viajes)
*
* "Opción Genérico": Es una promoción canjeable de tipo Viaje,
* en la que el usuario puede determinar cuántos puntos utilizar.
*
* @return boolean
*/
public function esOpcionGenerica()
{
$categorias = $this->getCategorias();
$flujoCanje = $this->getFlujoCanje();
$esViaje=false;
foreach($categorias as $categoria){
if($categoria->getId() == 2){
$esViaje = true;
break;
}
}
// Comparar cadenas.
// "strcasecmp: Binary safe case-insensitive string comparison".
// retorna 0 si las cadenas son iguales, ignorando mayusculas.
$esGenerico = strcasecmp($flujoCanje, 'generico') == 0;

return $esViaje && $esGenerico;

}

/**
* Determina si la promoción es un viaje
* según las condición:
* - Id de la categoría asociada debe ser igual a 2 (Viajes)
*
* @return boolean
*/
public function esViaje()
{
$categorias = $this->getCategorias();
$esViaje=false;
foreach($categorias as $categoria){
if($categoria->getId() == 2){
$esViaje = true;
break;
}
}

return $esViaje;

}

/**
* Constructor
*/
public function __construct()
{
$this->imagenes = new DoctrineCommonCollectionsArrayCollection();
$this->categorias = new DoctrineCommonCollectionsArrayCollection();
$this->etiquetas = new DoctrineCommonCollectionsArrayCollection();
}

/**
* Get imagenes
*
* @return DoctrineCommonCollectionsCollection
*/
public function getImagenes()
{
return $this->imagenes;
}

/**
* Set destacado
*
* @param boolean $destacado
* @return Exppromociones
*/
public function setDestacado($destacado)
{
$this->destacado = $destacado;

return $this;
}

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

/**
* Add categorias
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias
* @return Exppromociones
*/
public function addCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias)
{
$this->categorias = $categorias;

return $this;
}

/**
* Remove categorias
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias
*/
public function removeCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias)
{
$this->categorias->removeElement($categorias);
}

/**
* Get categorias
*
* @return DoctrineCommonCollectionsCollection
*/
public function getCategorias()
{
return $this->categorias;
}


/**
* Add imagenes
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes
* @return Exppromociones
*/
public function addImagene(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes)
{
$this->imagenes = $imagenes;

return $this;
}

/**
* Remove imagenes
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes
*/
public function removeImagene(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes)
{
$this->imagenes->removeElement($imagenes);
}

/**
* Add etiquetas
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas
* @return Exppromociones
*/
public function addEtiqueta(ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas)
{
$this->etiquetas = $etiquetas;

return $this;
}

/**
* Remove etiquetas
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas
*/
public function removeEtiqueta(ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas)
{
$this->etiquetas->removeElement($etiquetas);
}

/**
* Get etiquetas
*
* @return DoctrineCommonCollectionsCollection
*/
public function getEtiquetas()
{
return $this->etiquetas;
}

/**
* Set fechaFinNovedad
*
* @param DateTime $fechaFinNovedad
* @return Exppromociones
*/
public function setFechaFinNovedad($fechaFinNovedad)
{
$this->fechaFinNovedad = $fechaFinNovedad;

return $this;
}

/**
* Get fechaFinNovedad
*
* @return DateTime
*/
public function getFechaFinNovedad()
{
return $this->fechaFinNovedad;
}

/**
* Set cantidadVista
*
* @param integer $cantidadVista
* @return Exppromociones
*/
public function setCantidadVista($cantidadVista)
{
$this->cantidadVista = $cantidadVista;

return $this;
}

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

/**
* Set cantidadCanjeada
*
* @param integer $cantidadCanjeada
* @return Exppromociones
*/
public function setCantidadCanjeada($cantidadCanjeada)
{
$this->cantidadCanjeada = $cantidadCanjeada;

return $this;
}

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

/**
* Set valorGuaranies
*
* @param integer $valorGuaranies
* @return Exppromociones
*/
public function setValorGuaranies($valorGuaranies)
{
$this->valorGuaranies = $valorGuaranies;

return $this;
}

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

/**
* Set puntosTelefonico
*
* @param integer $puntosTelefonico
* @return Exppromociones
*/
public function setPuntosTelefonico($puntosTelefonico)
{
$this->puntosTelefonico = $puntosTelefonico;

return $this;
}

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

/**
* Set texto_circulo
*
* @param string $textoCirculo
* @return Exppromociones
*/
public function setTextoCirculo($textoCirculo)
{
$this->texto_circulo = $textoCirculo;

return $this;
}

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

public function __toString()
{
return $this->getNombre();
}

/**
* Set mostrarValorGuaranies
*
* @param boolean $mostrarValorGuaranies
* @return Exppromociones
*/
public function setMostrarValorGuaranies($mostrarValorGuaranies)
{
$this->mostrarValorGuaranies = $mostrarValorGuaranies;

return $this;
}

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


This entity Exppromociones has an attribute $imagenes, which has instances of another entity Imagenes
Imagenes.php



<?php

namespace ROSHKABBVASitioUniversosImagenesBundleEntity;

use IphpFileStoreBundleMappingAnnotation as FileStore;
use SymfonyComponentValidatorConstraints as Assert;
use DoctrineORMMapping as ORM;

/**
* Imagenes
*
* @ORMTable(name="imagenes")
* @ORMEntity
* @FileStoreUploadable
*/
class Imagenes
{
/**
* @var integer
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @var string
*
* @ORMColumn(name="Nombre", type="string", length=255)
*/
private $nombre;


/**
* @var Datetime
*
* @ORMColumn(name="Fecha_Carga", type="date")
*/
private $fechaCarga;

/**
* @ORMColumn(name="Enlace", type="array")
* @AssertFile( maxSize="20M")
* @FileStoreUploadableField(mapping="imagenes")
**/
private $enlace;

/**
* @var string
*
* @ORMColumn(name="Tipo", type="string", length=255)
*/
private $tipo;

/**
* @var string
*
* @ORMColumn(name="Link", type="string", length=255)
*/
private $link;


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

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

return $this;
}

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

/**
* Set fechaCarga
*
* @param DateTime $fechaCarga
* @return Imagenes
*/
public function setFechaCarga($fechaCarga)
{
$this->fechaCarga = $fechaCarga;

return $this;
}

/**
* Get fechaCarga
*
* @return DateTime
*/
public function getFechaCarga()
{
return $this->fechaCarga;
}

/**
* Set enlace
*
* @param array $enlace
* @return Imagenes
*/
public function setEnlace($enlace)
{
$this->enlace = $enlace;

return $this;
}

/**
* Get enlace
*
* @return array
*/
public function getEnlace()
{
return $this->enlace;
}

public function __toString()
{
return $this->getNombre();
}

/**
* Set tipo
*
* @param string $tipo
* @return Imagenes
*/
public function setTipo($tipo)
{
$this->tipo = $tipo;

return $this;
}

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

/**
* Set link
*
* @param string $link
* @return Imagenes
*/
public function setLink($link)
{
$this->link = $link;

return $this;
}

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

public function __construct(){
$this->fechaCarga = new DateTime();
}
}


I want to see al the images from Imagenes that aren't associated to Exppromociones



mapping:



ROSHKABBVASitioExperienceFrontendBundleEntityExppromociones:
type: entity
table: exppromociones
indexes:
IDX_4EE4A008763C8AA7:
columns:
- imagen_id
IDX_4EE4A008684EC833:
columns:
- banner_id
IDX_4EE4A0083397707A:
columns:
- categoria_id
IDX_COMERCIOS_PROMOCION:
columns:
- comercio_id
id:
id:
type: integer
nullable: false
unsigned: false
comment: ''
id: true
generator:
strategy: IDENTITY
fields:
...
...
manyToMany:
imagenes:
cascade: ["persist","remove"]
targetEntity: ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
joinTable:
name: imagenes_x_exppromociones
joinColumns:
id_promocion:
referencedColumnName: id
inverseJoinColumns:
id_imagen:
referencedColumnName: id
unique: true
lifecycleCallbacks: { }









share|improve this question















Full Error



CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 170 near 'imagenes WHERE': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.") in "ROSHKABBVASitioExperienceBackendBundle:ExpPromociones:new.html.twig" at line 40." at C:xampphtdocsbbva-universosappcacheuniversos_devclasses.php line 4440 


I have two Queries to select all the elements of A that aren't in B, but I can't get to translate it to Doctrine



SELECT * 
FROM beneficiobbva.imagenes im
LEFT JOIN beneficiobbva.imagenes_x_exppromociones impro
ON im.id=impro.id_imagen
where impro.id_imagen is null;


OR



select *
from beneficiobbva.imagenes a
where a.id
NOT IN (
SELECT id_imagen
FROM beneficiobbva.imagenes_x_exppromociones
);


With doctrine I tried to do something like this but I get an error Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected."



This is my code:



    $imagenes = $em->createQueryBuilder()
->select('img')
->addSelect('img_pro')
->from('ROSHKABBVASitioUniversosImagenesBundle:Imagenes', 'img')
->leftjoin('ROSHKABBVASitioExperienceFrontendBundle:Exppromociones', 'img_pro', 'WITH', 'img.id=img_pro.imagenes')
->where('img_pro.imagenes is null')
->getQuery()
->getResult();


I have one entity which is Exppromociones.php
This is part of my entity, I think this is all you need because it's really long



    <?php

namespace ROSHKABBVASitioExperienceFrontendBundleEntity;

use DoctrineORMMapping as ORM;

/**
* Exppromociones
*/
class Exppromociones
{
/**
* @var integer
*/
private $id;

/**
* @var string
*/
private $nombre;

/**
* @var string
*/
private $descripcion;

/**
* @var integer
*/
private $puntos;

/**
* @var DateTime
*/
private $fechaInicio;

/**
* @var DateTime
*/
private $fechaFin;

/**
* @var boolean
*/
private $enPromocion;

/**
* @var string
*/
private $vigenciaDescripcion;

/**
* @var string
*/
private $miniDescripcion;

/**
* @var integer
*/
private $puntosOtros;

/**
* @var string
*/
private $flujoCanje;

/**
* @var ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias
*/
private $categoria;

/**
* @var ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
private $banner;

/**
* @var ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
private $imagen;

/**
* @var ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios
*/
private $comercio;

/**
* @var string
*
* @ORMColumn(name="Nombre_Real", type="text")
*/
private $nombreReal;

/**
* @var string
*
* @ORMColumn(name="Descripcion_Experience", type="text")
*/
private $descripcionExperience;

/**
* @var boolean
*/
private $destacado = false;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $imagenes;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $categorias;

/**
* @var DoctrineCommonCollectionsCollection
*/
private $etiquetas;

/**
* @var DateTime
*/
private $fechaFinNovedad;

/**
* @var integer
*/
private $cantidadVista = 0;

/**
* @var integer
*/
private $cantidadCanjeada = 0;

/**
* @var integer
*/
private $valorGuaranies = 0;

/**
* @var integer
*/
private $puntosTelefonico;

/**
* @var string
*/
private $texto_circulo;

/**
* @var boolean
*/
private $mostrarValorGuaranies;


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

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

return $this;
}

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

/**
* Set descripcion
*
* @param string $descripcion
* @return Exppromociones
*/
public function setDescripcion($descripcion)
{
$this->descripcion = $descripcion;

return $this;
}

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

/**
* Set puntos
*
* @param integer $puntos
* @return Exppromociones
*/
public function setPuntos($puntos)
{
$this->puntos = $puntos;

return $this;
}

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

/**
* Set fechaInicio
*
* @param DateTime $fechaInicio
* @return Exppromociones
*/
public function setFechaInicio($fechaInicio)
{
$this->fechaInicio = $fechaInicio;

return $this;
}

/**
* Get fechaInicio
*
* @return DateTime
*/
public function getFechaInicio()
{
return $this->fechaInicio;
}

/**
* Set fechaFin
*
* @param DateTime $fechaFin
* @return Exppromociones
*/
public function setFechaFin($fechaFin)
{
$this->fechaFin = $fechaFin;

return $this;
}

/**
* Get fechaFin
*
* @return DateTime
*/
public function getFechaFin()
{
return $this->fechaFin;
}

/**
* Set enPromocion
*
* @param boolean $enPromocion
* @return Exppromociones
*/
public function setEnPromocion($enPromocion)
{
$this->enPromocion = $enPromocion;

return $this;
}

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

/**
* Set vigenciaDescripcion
*
* @param string $vigenciaDescripcion
* @return Exppromociones
*/
public function setVigenciaDescripcion($vigenciaDescripcion)
{
$this->vigenciaDescripcion = $vigenciaDescripcion;

return $this;
}

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

/**
* Set miniDescripcion
*
* @param string $miniDescripcion
* @return Exppromociones
*/
public function setMiniDescripcion($miniDescripcion)
{
$this->miniDescripcion = $miniDescripcion;

return $this;
}

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

/**
* Set puntosOtros
*
* @param integer $puntosOtros
* @return Exppromociones
*/
public function setPuntosOtros($puntosOtros)
{
$this->puntosOtros = $puntosOtros;

return $this;
}

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

/**
* Set flujoCanje
*
* @param string $flujoCanje
* @return Exppromociones
*/
public function setFlujoCanje($flujoCanje)
{
$this->flujoCanje = $flujoCanje;

return $this;
}

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

/**
* Set categoria
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias $categoria
* @return Exppromociones
*/
public function setCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias $categoria = null)
{
$this->categoria = $categoria;

return $this;
}

/**
* Get categoria
*
* @return ROSHKABBVASitioExperienceFrontendBundleEntityExpCategorias
*/
public function getCategoria()
{
return $this->categoria;
}

/**
* Set banner
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $banner
* @return Exppromociones
*/
public function setBanner(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $banner = null)
{
$this->banner = $banner;

return $this;
}

/**
* Get banner
*
* @return ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
*/
public function getBanner()
{
return $this->banner;
}

/**
* Set imagen
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagen
* @return Exppromociones
*/
public function setImagen(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagen = null)
{
$this->imagen = $imagen;

return $this;
}

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

/**
* Set comercio
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios $comercio
* @return Exppromociones
*/
public function setComercio(ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios $comercio = null)
{
$this->comercio = $comercio;

return $this;
}

/**
* Get comercio
*
* @return ROSHKABBVASitioExperienceFrontendBundleEntityexpcomercios
*/
public function getComercio()
{
return $this->comercio;
}

/**
* Set nombreReal
*
* @param string $nombreReal
* @return ExpPromociones
*/
public function setNombreReal($nombreReal)
{
$this->nombreReal = $nombreReal;

return $this;
}

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

/**
* Set descripcionExperience
*
* @param string $descripcionExperience
* @return ExpPromociones
*/
public function setDescripcionExperience($descripcionExperience)
{
$this->descripcionExperience = $descripcionExperience;

return $this;
}

/**
* Get descripcionExperience
*
* @return string
*/
public function getDescripcionExperience()
{
return $this->descripcionExperience;
}
/**
* @var integer
*/
private $orden = 0;


/**
* Set orden
*
* @param integer $orden
* @return Exppromociones
*/
public function setOrden($orden)
{
$this->orden = $orden;

return $this;
}

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

/**
* Determina si la promoción es un viaje genérico,
* según las condición:
* - $flujoCanje de la instancia debe ser igual al string 'generico', y
* - Id de la categoría asociada debe ser igual a 2 (Viajes)
*
* "Opción Genérico": Es una promoción canjeable de tipo Viaje,
* en la que el usuario puede determinar cuántos puntos utilizar.
*
* @return boolean
*/
public function esOpcionGenerica()
{
$categorias = $this->getCategorias();
$flujoCanje = $this->getFlujoCanje();
$esViaje=false;
foreach($categorias as $categoria){
if($categoria->getId() == 2){
$esViaje = true;
break;
}
}
// Comparar cadenas.
// "strcasecmp: Binary safe case-insensitive string comparison".
// retorna 0 si las cadenas son iguales, ignorando mayusculas.
$esGenerico = strcasecmp($flujoCanje, 'generico') == 0;

return $esViaje && $esGenerico;

}

/**
* Determina si la promoción es un viaje
* según las condición:
* - Id de la categoría asociada debe ser igual a 2 (Viajes)
*
* @return boolean
*/
public function esViaje()
{
$categorias = $this->getCategorias();
$esViaje=false;
foreach($categorias as $categoria){
if($categoria->getId() == 2){
$esViaje = true;
break;
}
}

return $esViaje;

}

/**
* Constructor
*/
public function __construct()
{
$this->imagenes = new DoctrineCommonCollectionsArrayCollection();
$this->categorias = new DoctrineCommonCollectionsArrayCollection();
$this->etiquetas = new DoctrineCommonCollectionsArrayCollection();
}

/**
* Get imagenes
*
* @return DoctrineCommonCollectionsCollection
*/
public function getImagenes()
{
return $this->imagenes;
}

/**
* Set destacado
*
* @param boolean $destacado
* @return Exppromociones
*/
public function setDestacado($destacado)
{
$this->destacado = $destacado;

return $this;
}

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

/**
* Add categorias
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias
* @return Exppromociones
*/
public function addCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias)
{
$this->categorias = $categorias;

return $this;
}

/**
* Remove categorias
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias
*/
public function removeCategoria(ROSHKABBVASitioExperienceFrontendBundleEntityExpcategorias $categorias)
{
$this->categorias->removeElement($categorias);
}

/**
* Get categorias
*
* @return DoctrineCommonCollectionsCollection
*/
public function getCategorias()
{
return $this->categorias;
}


/**
* Add imagenes
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes
* @return Exppromociones
*/
public function addImagene(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes)
{
$this->imagenes = $imagenes;

return $this;
}

/**
* Remove imagenes
*
* @param ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes
*/
public function removeImagene(ROSHKABBVASitioUniversosImagenesBundleEntityImagenes $imagenes)
{
$this->imagenes->removeElement($imagenes);
}

/**
* Add etiquetas
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas
* @return Exppromociones
*/
public function addEtiqueta(ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas)
{
$this->etiquetas = $etiquetas;

return $this;
}

/**
* Remove etiquetas
*
* @param ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas
*/
public function removeEtiqueta(ROSHKABBVASitioExperienceFrontendBundleEntityExpetiquetas $etiquetas)
{
$this->etiquetas->removeElement($etiquetas);
}

/**
* Get etiquetas
*
* @return DoctrineCommonCollectionsCollection
*/
public function getEtiquetas()
{
return $this->etiquetas;
}

/**
* Set fechaFinNovedad
*
* @param DateTime $fechaFinNovedad
* @return Exppromociones
*/
public function setFechaFinNovedad($fechaFinNovedad)
{
$this->fechaFinNovedad = $fechaFinNovedad;

return $this;
}

/**
* Get fechaFinNovedad
*
* @return DateTime
*/
public function getFechaFinNovedad()
{
return $this->fechaFinNovedad;
}

/**
* Set cantidadVista
*
* @param integer $cantidadVista
* @return Exppromociones
*/
public function setCantidadVista($cantidadVista)
{
$this->cantidadVista = $cantidadVista;

return $this;
}

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

/**
* Set cantidadCanjeada
*
* @param integer $cantidadCanjeada
* @return Exppromociones
*/
public function setCantidadCanjeada($cantidadCanjeada)
{
$this->cantidadCanjeada = $cantidadCanjeada;

return $this;
}

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

/**
* Set valorGuaranies
*
* @param integer $valorGuaranies
* @return Exppromociones
*/
public function setValorGuaranies($valorGuaranies)
{
$this->valorGuaranies = $valorGuaranies;

return $this;
}

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

/**
* Set puntosTelefonico
*
* @param integer $puntosTelefonico
* @return Exppromociones
*/
public function setPuntosTelefonico($puntosTelefonico)
{
$this->puntosTelefonico = $puntosTelefonico;

return $this;
}

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

/**
* Set texto_circulo
*
* @param string $textoCirculo
* @return Exppromociones
*/
public function setTextoCirculo($textoCirculo)
{
$this->texto_circulo = $textoCirculo;

return $this;
}

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

public function __toString()
{
return $this->getNombre();
}

/**
* Set mostrarValorGuaranies
*
* @param boolean $mostrarValorGuaranies
* @return Exppromociones
*/
public function setMostrarValorGuaranies($mostrarValorGuaranies)
{
$this->mostrarValorGuaranies = $mostrarValorGuaranies;

return $this;
}

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


This entity Exppromociones has an attribute $imagenes, which has instances of another entity Imagenes
Imagenes.php



<?php

namespace ROSHKABBVASitioUniversosImagenesBundleEntity;

use IphpFileStoreBundleMappingAnnotation as FileStore;
use SymfonyComponentValidatorConstraints as Assert;
use DoctrineORMMapping as ORM;

/**
* Imagenes
*
* @ORMTable(name="imagenes")
* @ORMEntity
* @FileStoreUploadable
*/
class Imagenes
{
/**
* @var integer
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @var string
*
* @ORMColumn(name="Nombre", type="string", length=255)
*/
private $nombre;


/**
* @var Datetime
*
* @ORMColumn(name="Fecha_Carga", type="date")
*/
private $fechaCarga;

/**
* @ORMColumn(name="Enlace", type="array")
* @AssertFile( maxSize="20M")
* @FileStoreUploadableField(mapping="imagenes")
**/
private $enlace;

/**
* @var string
*
* @ORMColumn(name="Tipo", type="string", length=255)
*/
private $tipo;

/**
* @var string
*
* @ORMColumn(name="Link", type="string", length=255)
*/
private $link;


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

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

return $this;
}

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

/**
* Set fechaCarga
*
* @param DateTime $fechaCarga
* @return Imagenes
*/
public function setFechaCarga($fechaCarga)
{
$this->fechaCarga = $fechaCarga;

return $this;
}

/**
* Get fechaCarga
*
* @return DateTime
*/
public function getFechaCarga()
{
return $this->fechaCarga;
}

/**
* Set enlace
*
* @param array $enlace
* @return Imagenes
*/
public function setEnlace($enlace)
{
$this->enlace = $enlace;

return $this;
}

/**
* Get enlace
*
* @return array
*/
public function getEnlace()
{
return $this->enlace;
}

public function __toString()
{
return $this->getNombre();
}

/**
* Set tipo
*
* @param string $tipo
* @return Imagenes
*/
public function setTipo($tipo)
{
$this->tipo = $tipo;

return $this;
}

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

/**
* Set link
*
* @param string $link
* @return Imagenes
*/
public function setLink($link)
{
$this->link = $link;

return $this;
}

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

public function __construct(){
$this->fechaCarga = new DateTime();
}
}


I want to see al the images from Imagenes that aren't associated to Exppromociones



mapping:



ROSHKABBVASitioExperienceFrontendBundleEntityExppromociones:
type: entity
table: exppromociones
indexes:
IDX_4EE4A008763C8AA7:
columns:
- imagen_id
IDX_4EE4A008684EC833:
columns:
- banner_id
IDX_4EE4A0083397707A:
columns:
- categoria_id
IDX_COMERCIOS_PROMOCION:
columns:
- comercio_id
id:
id:
type: integer
nullable: false
unsigned: false
comment: ''
id: true
generator:
strategy: IDENTITY
fields:
...
...
manyToMany:
imagenes:
cascade: ["persist","remove"]
targetEntity: ROSHKABBVASitioUniversosImagenesBundleEntityImagenes
joinTable:
name: imagenes_x_exppromociones
joinColumns:
id_promocion:
referencedColumnName: id
inverseJoinColumns:
id_imagen:
referencedColumnName: id
unique: true
lifecycleCallbacks: { }






php symfony doctrine






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 20:36

























asked Nov 12 at 15:01









Xav

11




11












  • Could you try >where('img_pro is null')
    – Ahmed bhs
    Nov 12 at 15:13










  • Not working, I get an error before that line in 'img.id=img_pro.image_id', i think it says image_id has multiple values and is expecting a singlevaluedassociationfield.
    – Xav
    Nov 12 at 15:19










  • With Doctrine, you're able to use native SQL queries. You can find more information here: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/… There's no need to translate all the query to Doctrine, and with the native query you're going to have a better performance.
    – J. Almandos
    Nov 12 at 15:20












  • Also, you can use DQL that is pretty similar to SQL: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/…
    – J. Almandos
    Nov 12 at 15:23










  • Thanks! I'll take a look at those links
    – Xav
    Nov 12 at 15:27


















  • Could you try >where('img_pro is null')
    – Ahmed bhs
    Nov 12 at 15:13










  • Not working, I get an error before that line in 'img.id=img_pro.image_id', i think it says image_id has multiple values and is expecting a singlevaluedassociationfield.
    – Xav
    Nov 12 at 15:19










  • With Doctrine, you're able to use native SQL queries. You can find more information here: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/… There's no need to translate all the query to Doctrine, and with the native query you're going to have a better performance.
    – J. Almandos
    Nov 12 at 15:20












  • Also, you can use DQL that is pretty similar to SQL: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/…
    – J. Almandos
    Nov 12 at 15:23










  • Thanks! I'll take a look at those links
    – Xav
    Nov 12 at 15:27
















Could you try >where('img_pro is null')
– Ahmed bhs
Nov 12 at 15:13




Could you try >where('img_pro is null')
– Ahmed bhs
Nov 12 at 15:13












Not working, I get an error before that line in 'img.id=img_pro.image_id', i think it says image_id has multiple values and is expecting a singlevaluedassociationfield.
– Xav
Nov 12 at 15:19




Not working, I get an error before that line in 'img.id=img_pro.image_id', i think it says image_id has multiple values and is expecting a singlevaluedassociationfield.
– Xav
Nov 12 at 15:19












With Doctrine, you're able to use native SQL queries. You can find more information here: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/… There's no need to translate all the query to Doctrine, and with the native query you're going to have a better performance.
– J. Almandos
Nov 12 at 15:20






With Doctrine, you're able to use native SQL queries. You can find more information here: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/… There's no need to translate all the query to Doctrine, and with the native query you're going to have a better performance.
– J. Almandos
Nov 12 at 15:20














Also, you can use DQL that is pretty similar to SQL: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/…
– J. Almandos
Nov 12 at 15:23




Also, you can use DQL that is pretty similar to SQL: doctrine-project.org/projects/doctrine-orm/en/2.6/reference/…
– J. Almandos
Nov 12 at 15:23












Thanks! I'll take a look at those links
– Xav
Nov 12 at 15:27




Thanks! I'll take a look at those links
– Xav
Nov 12 at 15:27












1 Answer
1






active

oldest

votes


















0














This post needs more information, so this is a hit/miss type answer:



img_pro.image_id looks suspect.



DQL uses the property names, not the field names, so it should be img_pro.image






share|improve this answer





















  • What else can I add?
    – Xav
    Nov 12 at 18:36










  • Full error message, full query builder, and entities. These type of errors are often due to a small mistake, which we cannot find if you obfuscate it. Have you tried to use image instead of image_id?
    – Padam87
    Nov 12 at 18:38










  • That was a mistake using "image_id" I corrected it
    – Xav
    Nov 12 at 18:50













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264860%2fdoctrine-get-all-elements-from-a-that-arent-in-b%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














This post needs more information, so this is a hit/miss type answer:



img_pro.image_id looks suspect.



DQL uses the property names, not the field names, so it should be img_pro.image






share|improve this answer





















  • What else can I add?
    – Xav
    Nov 12 at 18:36










  • Full error message, full query builder, and entities. These type of errors are often due to a small mistake, which we cannot find if you obfuscate it. Have you tried to use image instead of image_id?
    – Padam87
    Nov 12 at 18:38










  • That was a mistake using "image_id" I corrected it
    – Xav
    Nov 12 at 18:50


















0














This post needs more information, so this is a hit/miss type answer:



img_pro.image_id looks suspect.



DQL uses the property names, not the field names, so it should be img_pro.image






share|improve this answer





















  • What else can I add?
    – Xav
    Nov 12 at 18:36










  • Full error message, full query builder, and entities. These type of errors are often due to a small mistake, which we cannot find if you obfuscate it. Have you tried to use image instead of image_id?
    – Padam87
    Nov 12 at 18:38










  • That was a mistake using "image_id" I corrected it
    – Xav
    Nov 12 at 18:50
















0












0








0






This post needs more information, so this is a hit/miss type answer:



img_pro.image_id looks suspect.



DQL uses the property names, not the field names, so it should be img_pro.image






share|improve this answer












This post needs more information, so this is a hit/miss type answer:



img_pro.image_id looks suspect.



DQL uses the property names, not the field names, so it should be img_pro.image







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 at 16:22









Padam87

88657




88657












  • What else can I add?
    – Xav
    Nov 12 at 18:36










  • Full error message, full query builder, and entities. These type of errors are often due to a small mistake, which we cannot find if you obfuscate it. Have you tried to use image instead of image_id?
    – Padam87
    Nov 12 at 18:38










  • That was a mistake using "image_id" I corrected it
    – Xav
    Nov 12 at 18:50




















  • What else can I add?
    – Xav
    Nov 12 at 18:36










  • Full error message, full query builder, and entities. These type of errors are often due to a small mistake, which we cannot find if you obfuscate it. Have you tried to use image instead of image_id?
    – Padam87
    Nov 12 at 18:38










  • That was a mistake using "image_id" I corrected it
    – Xav
    Nov 12 at 18:50


















What else can I add?
– Xav
Nov 12 at 18:36




What else can I add?
– Xav
Nov 12 at 18:36












Full error message, full query builder, and entities. These type of errors are often due to a small mistake, which we cannot find if you obfuscate it. Have you tried to use image instead of image_id?
– Padam87
Nov 12 at 18:38




Full error message, full query builder, and entities. These type of errors are often due to a small mistake, which we cannot find if you obfuscate it. Have you tried to use image instead of image_id?
– Padam87
Nov 12 at 18:38












That was a mistake using "image_id" I corrected it
– Xav
Nov 12 at 18:50






That was a mistake using "image_id" I corrected it
– Xav
Nov 12 at 18:50




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264860%2fdoctrine-get-all-elements-from-a-that-arent-in-b%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python