I am trying to add a custom method to my repository. I need to execute a 'not equal to' query. So as this suggests i implemented the following.But i get an erroe like
FatalErrorException: Error: Call to undefined method System\VmsBundle\Entity\EntryDetails::createQueryBuilder() in ..\src\System\VmsBundle\Entity\EntryDetails.php line 208
In my entity
<?php
namespace System\VmsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
*@ORM\Entity(repositoryClass="System\VmsBundle\Entity\EntryRepository")
**/
/**
* EntryDetails
*/
class EntryDetails
{
.....
public function findByNot($field, $value)
{
$qb = $this->createQueryBuilder('a');
$qb->where($qb->expr()->not($qb->expr()->eq('a.'.$field, '?1')));
$qb->setParameter(1, $value);
return $qb->getQuery()->getResult();
}
}
In my controller
$entities = $this->getDoctrine()->getRepository('SystemVmsBundle:EntryDetails')->findByNot('exitTime', 1);
In my orm.xml file
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="System\VmsBundle\Entity\EntryDetails" table="entry_details" repository-class="System\VmsBundle\Entity\EntryDetails">
....
</entity>
</doctrine-mapping>
Also, when i try to execute the action involving findAll() method, it shows me undefined method error. How to fix this?