我正在使用 Symfony2。
这是我的对象播放器:
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="player")
*/
class Player
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
protected $name;
protected $urlAvatar;
/**
* @ORM\Column(type="integer")
*/
protected $coins;
/**
* @ORM\Column(type="integer")
*/
protected $money;
/**
* @ORM\OneToMany(targetEntity="Mercenary", mappedBy="player")
*/
protected $mercenaries;
public function __construct()
{
$this->mercenaries = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set coins
*
* @param integer $coins
*/
public function setCoins($coins)
{
$this->coins = $coins;
}
/**
* Get coins
*
* @return integer
*/
public function getCoins()
{
return $this->coins;
}
/**
* Set money
*
* @param integer $money
*/
public function setMoney($money)
{
$this->money = $money;
}
/**
* Get money
*
* @return integer
*/
public function getMoney()
{
return $this->money;
}
/**
* Add mercenaries
*
* @param IFZ\TowerofDimensionsBundle\Entity\Mercenary $mercenaries
*/
public function addMercenary(\IFZ\TowerofDimensionsBundle\Entity\Mercenary $mercenaries)
{
$this->mercenaries[] = $mercenaries;
}
/**
* Get mercenaries
*
* @return Doctrine\Common\Collections\Collection
*/
public function getMercenaries()
{
return $this->mercenaries;
}
}
我想阅读雇佣兵的信息,但我找不到方法。它返回一个 Doctrine 集合,但我无法继续并从集合中获取所有项目。我不想过滤它们,我只想获取所有项目。感谢阅读。