【发布时间】:2019-04-06 02:46:48
【问题描述】:
我遇到了与Symfony2 Doctrine Unrecognized field: 类似的问题 但是我的没有相同的解决方案
我有一个实体“类别”我正在尝试查找属性“activo”设置为 true 的所有类别,但它给了我标题中的错误
我已经完成了 php app/console 原则:generate:entities [path] --no-backup 和 php app/console 原则:schema:update --force
我的数据库中的表被更新为我的实体。
<?php
namespace ROSHKA\BBVA\SitioExperience\FrontendBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Expcategorias
*/
class Expcategorias
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $nombre;
/**
* @var string
*/
private $descripcion;
/**
* @var \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes
*/
private $imagen;
/**
* @var string
*/
private $titulo;
/**
* @var boolean
*/
private $activo;
/**
* @var string
*/
private $colorfondo;
/**
* @var \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes
*/
private $imagenfondo;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set nombre
*
* @param string $nombre
* @return Expcategorias
*/
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 Expcategorias
*/
public function setDescripcion($descripcion)
{
$this->descripcion = $descripcion;
return $this;
}
/**
* Get descripcion
*
* @return string
*/
public function getDescripcion()
{
return $this->descripcion;
}
/**
* Set imagen
*
* @param \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes $imagen
* @return Expcategorias
*/
public function setImagen(\ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes $imagen = null)
{
$this->imagen = $imagen;
return $this;
}
/**
* Get imagen
*
* @return \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes
*/
public function getImagen()
{
return $this->imagen;
}
public function __toString()
{
return $this->getNombre();
}
/**
* Set titulo
*
* @param string $titulo
* @return Expcategorias
*/
public function setTitulo($titulo)
{
$this->titulo = $titulo;
return $this;
}
/**
* Get titulo
*
* @return string
*/
public function getTitulo()
{
return $this->titulo;
}
/**
* Set activo
*
* @param boolean $activo
* @return Expcategorias
*/
public function setActivo($activo)
{
$this->activo = $activo;
return $this;
}
/**
* Get activo
*
* @return boolean
*/
public function getActivo()
{
return $this->activo;
}
/**
* Set colorfondo
*
* @param string $colorfondo
* @return Expcategorias
*/
public function setColorfondo($colorfondo)
{
$this->colorfondo = $colorfondo;
return $this;
}
/**
* Get colorfondo
*
* @return string
*/
public function getColorfondo()
{
return $this->colorfondo;
}
/**
* Set imagenfondo
*
* @param \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes $imagenfondo
* @return Expcategorias
*/
public function setImagenfondo(\ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes $imagenfondo = null)
{
$this->imagenfondo = $imagenfondo;
return $this;
}
/**
* Get imagenfondo
*
* @return \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes
*/
public function getImagenfondo()
{
return $this->imagenfondo;
}
}
这是我在我的控制器中用来调用它的。当我在这里调试并设置断点时,我可以在表达式部分看到我的类别只有三列,而不是应该有的 9 列。我不知道还能做什么。
$repo = $this->getDoctrine()->getRepository('ROSHKABBVASitioExperienceFrontendBundle:Expcategorias');
$categorias = $repo->findBy(array('activo'=>true));
【问题讨论】:
-
关于 Symfony 版本的概念:自 2016 年 5 月起不再支持 2.3!理想情况下,您应该移至 3.4。在新版本中情况发生了很大变化,寻找适用于 2.3 版的解决方案可能会浪费时间,因为您必须进行大量更改才能符合新版本。迁移到更新的稳定版本,然后尝试解决错误。
-
我很想迁移到最新版本,但这需要时间,而且这个项目属于我工作的公司,迁移到另一个版本不在计划中。
标签: php symfony doctrine symfony-2.3