Semantical Error: Class MailileoBundle\Entity\Match has no field or association named getMailid

Semantical Error: Class MailileoBundle\Entity\Match has no field or association named getMailid

我遇到了所有类似的问题,但似乎无法解决我的问题。 我在我的 MatchRepository 中放置了一个简单的查询,但它引发了语义错误。

我已经双重(三次)检查了我的实体,一切看起来都很好。当我通过 findAll() 然后 运行 a $match->getMailid() 拉所有比赛时,它甚至工作正常 该问题仅出现在 MatchRepository 文件中。

代码如下:

实体:

<?php 
namespace MailileoBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use MailileoBundle\Modules\DatabaseController;
use MailileoBundle\Entity\QueueItem;
use MailileoBundle\Entity\Message;
use Doctrine\Common\Collections\ArrayCollection;



/**
 * @ORM\Table(name="matches")
 * @ORM\Entity(repositoryClass="MailileoBundle\Entity\MatchRepository")
 */

class Match
{
/**
 * @ORM\Column(type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;


/**
 * @ORM\OneToMany(targetEntity="QueueItem", mappedBy="match")
 */
private $queueItems;

/**
 * @ORM\OneToMany(targetEntity="Message", mappedBy="match")
 */
private $messages;

/**
 * @ORM\Column(type="datetime")
 */
private $created;


/**
 * @ORM\Column(type="string", length=15)
 */
private $mailid;

/**
 * @ORM\Column(name="deleted", type="boolean")
 */
private $deleted;

/**
 * Get id
 *
 * @return integer
 */




public function __construct($items, $mailid) {
    
    foreach ($items as $item) {
        $this->queueItems[] = $item;
    }
    $this->mailid = $mailid;
    $this->created = new \DateTime("now");
    $this->deleted = false;
}
public function getId()
{
    return $this->id;

}

/**
 * Set matchtwo
 *
 * @param string $matchtwo
 *
 * @return Match
 */

/**
 * Set created
 *
 * @param \DateTime $created
 *
 * @return Match
 */
public function setCreated($created)
{
    $this->created = $created;

    return $this;
}

/**
 * Get created
 *
 * @return \DateTime
 */
public function getCreated()
{
    return $this->created;
}

/**
 * Set mailid
 *
 * @param string $mailid
 *
 * @return Match
 */
public function setMailid($mailid)
{
    $this->mailid = $mailid;

    return $this;
}

/**
 * Get mailid
 *
 * @return string
 */
public function getMailid()
{
    return $this->mailid;
}

/**
 * Set deleted
 *
 * @param boolean $deleted
 *
 * @return Match
 */
public function setDeleted($deleted)
{
    $this->deleted = $deleted;

    return $this;
}

/**
 * Get deleted
 *
 * @return boolean
 */
public function getDeleted()
{
    return $this->deleted;
}

/**
 * Add queueItem
 *
 * @param \MailileoBundle\Entity\QueueItem $queueItem
 *
 * @return Match
 */
public function addQueueItem(\MailileoBundle\Entity\QueueItem $queueItem)
{
    $this->queueItems[] = $queueItem;

    return $this;
}

/**
 * Remove queueItem
 *
 * @param \MailileoBundle\Entity\QueueItem $queueItem
 */
public function removeQueueItem(\MailileoBundle\Entity\QueueItem $queueItem)
{
    $this->queueItems->removeElement($queueItem);
}

/**
 * Get queueItems
 *
 * @return \Doctrine\Common\Collections\Collection
 */
public function getQueueItems()
{
    return $this->queueItems;
}

/**
 * Add message
 *
 * @param \MailileoBundle\Entity\Message $message
 *
 * @return Match
 */
public function addMessage(\MailileoBundle\Entity\Message $message)
{
    $this->messages[] = $message;

    return $this;
}

/**
 * Remove message
 *
 * @param \MailileoBundle\Entity\Message $message
 */
public function removeMessage(\MailileoBundle\Entity\Message $message)
{
    $this->messages->removeElement($message);
}

/**
 * Get messages
 *
 * @return \Doctrine\Common\Collections\Collection
 */
public function getMessages()
{
    return $this->messages;
}
}

这是存储库:

<?php

namespace MailileoBundle\Entity;

/**
 * MatchRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class MatchRepository extends \Doctrine\ORM\EntityRepository
{
public function findMatchForMailId($mailid) {

    $query =  $this->getEntityManager()->createQuery("SELECT q FROM MailileoBundle:Match as q WHERE q.getMailid = :mailid")->setParameter('mailid', $mailid);
    $item = $query->getOneOrNullResult();
    return $item;
    
}
}

我运行通过以下方式进行此操作:

$dbb = $this->container->get('doctrine.orm.entity_manager'); 
$match=$dbb->getRepository('MailileoBundle:Match')->findMatchForMailId($mailid);

这是我目前尝试过的方法:

我正在使用 symfony3。

有什么建议吗?谢谢!!!

好的,正如 Cerad 建议的那样,我应该使用 属性 名称而不是 getter。