I went through all similar issues but nothing appears to solve my problem.
I’ve put a simple query in my MatchRepository
but it throws a semantic error.
I’ve double(triple) checked my entity and everything looks fine. It even works fine when I pull all Matches via findAll()
and then run a $match->getMailid()
The problem appears only in the MatchRepository
file.
Here’s the code:
Entity:
<?php namespace MailileoBundleEntity; use DoctrineORMMapping as ORM; use SymfonyComponentValidatorConstraints as Assert; use SymfonyBridgeDoctrineValidatorConstraintsUniqueEntity; use MailileoBundleModulesDatabaseController; use MailileoBundleEntityQueueItem; use MailileoBundleEntityMessage; use DoctrineCommonCollectionsArrayCollection; /** * @ORMTable(name="matches") * @ORMEntity(repositoryClass="MailileoBundleEntityMatchRepository") */ class Match { /** * @ORMColumn(type="integer") * @ORMId * @ORMGeneratedValue(strategy="AUTO") */ private $id; /** * @ORMOneToMany(targetEntity="QueueItem", mappedBy="match") */ private $queueItems; /** * @ORMOneToMany(targetEntity="Message", mappedBy="match") */ private $messages; /** * @ORMColumn(type="datetime") */ private $created; /** * @ORMColumn(type="string", length=15) */ private $mailid; /** * @ORMColumn(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 MailileoBundleEntityQueueItem $queueItem * * @return Match */ public function addQueueItem(MailileoBundleEntityQueueItem $queueItem) { $this->queueItems[] = $queueItem; return $this; } /** * Remove queueItem * * @param MailileoBundleEntityQueueItem $queueItem */ public function removeQueueItem(MailileoBundleEntityQueueItem $queueItem) { $this->queueItems->removeElement($queueItem); } /** * Get queueItems * * @return DoctrineCommonCollectionsCollection */ public function getQueueItems() { return $this->queueItems; } /** * Add message * * @param MailileoBundleEntityMessage $message * * @return Match */ public function addMessage(MailileoBundleEntityMessage $message) { $this->messages[] = $message; return $this; } /** * Remove message * * @param MailileoBundleEntityMessage $message */ public function removeMessage(MailileoBundleEntityMessage $message) { $this->messages->removeElement($message); } /** * Get messages * * @return DoctrineCommonCollectionsCollection */ public function getMessages() { return $this->messages; } }
Here’s the repository:
<?php namespace MailileoBundleEntity; /** * MatchRepository * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. */ class MatchRepository extends DoctrineORMEntityRepository { 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; } }
and I’m running this via:
$dbb = $this->container->get('doctrine.orm.entity_manager'); $match=$dbb->getRepository('MailileoBundle:Match')->findMatchForMailId($mailid);
Here’s what I’ve tried so far:
- clearing cache
- updating entities/DB schema via console
- restarting server
- using
q.mailid
instead ofgetMailid()
I’m using symfony3.
Any advices? Thanks!!!
Advertisement
Answer
OK as Cerad had suggested I should use a property name not a getter.