【发布时间】:2011-11-30 06:37:27
【问题描述】:
我正在尝试使用我的实体类和存储库类之一从 symfony2 和教义中的数据库中获取对象。
这里是函数调用:
$game = $em->getRepository('MLBPBeerBundle:TableGame')->findBygameId($gid);
$game.setZoneTableid('20');
这是我的存储库类的 sn-p:
class TableGameRepository extends EntityRepository
{
public function findBygameId($gid)
{
return $this->getEntityManager()
->createQuery('SELECT g FROM MLBPBeerBundle:TableGame g WHERE g.gameId = ' . $gid)
->getSingleResult();
}
这是我的实体类的 sn-p:
/**
* MLBP\BeerBundle\Entity\TableGame
*
* @ORM\Table(name="table_game")
* @ORM\Entity(repositoryClass="MLBP\BeerBundle\Repository\TableGameRepository")
*
*/
class TableGame
{
/**
* @var TableTable
*
* @ORM\ManyToOne(targetEntity="TableTable")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="ZONE_TABLEID", referencedColumnName="TABLE_ID")
* })
*/
protected $zoneTableid;
/**
* Set zoneTableid
*
* @param MLBP\BeerBundle\Entity\TableTable $zoneTableid
*/
public function setZoneTableid(\MLBP\BeerBundle\Entity\TableTable $zoneTableid)
{
$this->zoneTableid = $zoneTableid;
}
这是我的错误信息:
调用未定义函数 MLBP\BeerBundle\Controller\setZoneTableid() 谢谢!
【问题讨论】: