【发布时间】:2016-02-29 05:15:53
【问题描述】:
findAll() 在我的存储库中找到一个结果:
$retorno[] = $bd->getEntityManager()->getRepository($classname)->findAll();
实体类:
<?php
use Doctrine\ORM\Mapping as ORM;
/**
* Subtipo
*
* @ORM\Table(name="subtipo", indexes={@ORM\Index(name="fk_Subtipo_Tipo1_idx", columns={"Tipo_id"})})
* @ORM\Entity
*/
class Subtipo
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="nome", type="string", length=45, nullable=false)
*/
private $nome;
/**
* @var \Tipo
*
* @ORM\ManyToOne(targetEntity="Tipo")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="Tipo_id", referencedColumnName="id")
* })
*/
private $tipo;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set nome
*
* @param string $nome
*
* @return Subtipo
*/
public function setNome($nome)
{
$this->nome = $nome;
return $this;
}
/**
* Get nome
*
* @return string
*/
public function getNome()
{
return $this->nome;
}
/**
* Set tipo
*
* @param \Tipo $tipo
*
* @return Subtipo
*/
public function setTipo(\Tipo $tipo = null)
{
$this->tipo = $tipo;
return $this;
}
/**
* Get tipo
*
* @return \Tipo
*/
public function getTipo()
{
return $this->tipo;
}
}
有人可以帮忙吗?
【问题讨论】:
-
因为 findAll 方法调用看起来是正确的,只是一些非常基本的东西:您可能在“subtipo”表中有多个条目?您如何检查结果集合的长度?
标签: php symfony orm doctrine-orm doctrine