How to map and use a DB view from Doctrine2

I have an idea about the nomencladores schema obtenerPaisesPorFabricanteProductoSolicitud . This is the content to represent:

 SELECT ps.id AS psid, ps.nombre, fps.id AS fpsid FROM ( ( nomencladores.pais ps JOIN nomencladores.pais_fabricante_producto_solicitud pfps ON ((pfps.pais_id = ps.id)) ) JOIN negocio.fabricante_producto_solicitud fps ON ( ( pfps.fabricante_producto_solicitud_id = fps.id ) ) ); 

I am trying to display the view as follows:

 use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="nomencladores.obtenerPaisesPorFabricanteProductoSolicitud", schema="nomencladores") */ class ObtenerPaisesPorFabricanteProductoSolicitud { /** * @ORM\Id * @ORM\Column(name="psid", type="integer", nullable=false, unique=true) */ protected $ps; /** * @ORM\Column(name="fpsid", type="integer") */ protected $fps; /** * @ORM\Column(name="nombre", type="string") */ protected $nombre; public function getPs() { return $this->ps; } public function getFps() { return $this->fps; } public function getNombre() { return $this->nombre; } } 

But anytime I run this code on it:

 $ent = $em->getRepository("AppBundle:ObtenerPaisesPorFabricanteProductoSolicitud")->findBy( array( "fps" => $entF->getId() ) ); 

I got this result:

An exception occurred while executing 'SELECT t0.psid AS psid1, t0.fpsid AS fpsid2, t0.nombre AS nombre3 FROM nomencladores.obtenerPaisesPorFabricanteProductoSolicitud t0 WHERE t0.fpsid =? 'with parameters [22]: SQLSTATE [42P01]: Undefined table: 7 ERROR: relation "nomencladores.obtenerpaisesporfabricanteproductosolicitud" does not exist LINE 1: ... d1, t0.fpsid AS fpsid2, t0.nombre AS nombre3 FROM nomenclado ...

If I remove the annotations then error conversion:

The class "AppBundle \ Entity \ ObtenerPaisesPorFabricanteProductoSolicitud" is not a valid entity or mapped superclass. "

Why is Doctrine2 or Symfony trying to execute the request, instead view the view? How can I perform a view from Symfony2 / Doctrine2?

EDIT

As a side note, I use PostgreSQL as a DB, and it has several squemas, in this case I wrote a view in nomencladores schemas, but I tried putting also in the public schema, and no one seems to work, apparently Doctrine doesn't find idea of ​​the scheme

+2
source share

Source: https://habr.com/ru/post/956426/


All Articles