php - Call to a member function createQuery() on a non-object in symfony2 -


but have added @orm\entity(repositoryclass="repair\storebundle\entity\registrationrepository") in registration entity, i'm still getting error near createquery();

my registrationrepository.php is

use doctrine\orm\entityrepository;  /**  * registrationrepository  *  * class generated doctrine orm. add own custom  * repository methods below.  */  class registrationrepository extends entityrepository {      function __construct() {     }      public function auth($name,$password)     {         $em = $this->getentitymanager();          $result = $em->createquery("select r.username,r.password repairstorebundle:registration r r.username='".$name."' , r.password='".$password."'")->getresult();         return  $query;      }    } 

my controller calling in way

$test = new registrationrepository(); $result = $test->auth($name); 

creating new registrationrepository(instantiating) in controller manualy wrong way of doing it. instead have use doctrine getrepository method:

$em = $this->getdoctrine()->getmanager(); $registrationrepo = $em->getrepository('repairstorebundle:registration'); $result = $registrationrepo ->auth($name); 

read the docs.

update

also should remove __construct method repository class.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -