I'm having trouble with theory 2 and symfony2 I'm trying to create a group repository and I get this error Invalid parameter number: The number of bound variables does not match the number of tokens
I have seen the principle 2 syntax for determining why my createQueryBuilder object is my where Was bothering with the (assistant) function and it looks like I'm doing everything right Broar is my code:
& lt ;? Php namespace blogger \ blogbundle \ unit \ repository; Use the principle / ORM \ EntityRepository; / ** * Group Repository * This class was created by the principle ORM below to add your own custom * repository methods * / class group repository EntityRepository {public function getGroupByName ($ name) {$ $ - $ return-> createQueryBuilder ('G') - & gt; Select ('g') - & gt; Where ('g.name =:' $ .name) - & gt; GetQuery () - & gt; GetSingleResult (); }}
setParameter () Here is the key to success Read more about .... public function getGroupByName ($ name) {return $ this- & gt; CreateQueryBuilder ('g') - & gt; Where ('G.name =: name') - & gt; SetParameter ('name', $ name) - & gt; GetQuery () - & gt; GetSingleResult (); }
No comments:
Post a Comment