我对名为nomencladores
的{{1}}架构有一个看法。这是视图的内容:
obtenerPaisesPorFabricanteProductoSolicitud
我正在尝试将视图映射如下:
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
)
)
);
但是每当我在其上运行此代码时:
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;
}
}
我得到了这个结果:
执行'SELECT t0.psid AS psid1时发生异常, t0.fpsid AS fpsid2,t0.nombre AS nombre3 FROM nomencladores.obtenerPaisesPorFabricanteProductoSolicitud t0 WHERE t0.fpsid =?'与params [22]: SQLSTATE [42P01]:未定义的表:7错误:关系“nomencladores.obtenerpaisesporfabricanteproductosolicitud”不 存在LINE 1:... d1,t0.fpsid AS fpsid2,t0.nombre AS nombre3 FROM nomenclado ...
如果我删除了注释,那么错误转换为:
“类 “的appbundle \实体\ ObtenerPaisesPorFabricanteProductoSolicitud” 不是有效的实体或映射的超类。“
为什么Doctrine2或Symfony尝试执行查询而不是通过视图?我如何从Symfony2 / Doctrine2那边执行视图?
编辑
作为旁注,我使用PostgreSQL作为数据库并且它有几个squema,在这种情况下我在$ent = $em->getRepository("AppBundle:ObtenerPaisesPorFabricanteProductoSolicitud")->findBy(
array(
"fps" => $entF->getId()
)
);
模式中编写了视图,但我也尝试将它放在nomencladores
模式中,但没有一个工作,显然,Doctrine没有在架构上找到视图