@@ -36,20 +36,20 @@ public function __construct(ManagerRegistry $registry)
3636 public function getCount ($ collection , $ column , $ value , $ excludeId = null , $ idColumn = null , array $ extra = [])
3737 {
3838 $ builder = $ this ->select ($ collection );
39- $ builder ->where ("e. {$ column } = : { $ column}" );
39+ $ builder ->where ("e. {$ column } = : " . $ this -> prepareParam ( $ column) );
4040
4141 if (!is_null ($ excludeId ) && $ excludeId != 'NULL ' ) {
4242 $ idColumn = $ idColumn ?: 'id ' ;
43- $ builder ->andWhere ("e. {$ idColumn } <> : { $ idColumn}" );
43+ $ builder ->andWhere ("e. {$ idColumn } <> : " . $ this -> prepareParam ( $ idColumn) );
4444 }
4545
4646 $ this ->queryExtraConditions ($ extra , $ builder );
4747
4848 $ query = $ builder ->getQuery ();
49- $ query ->setParameter ($ column , $ value );
49+ $ query ->setParameter ($ this -> prepareParam ( $ column) , $ value );
5050
5151 if (!is_null ($ excludeId ) && $ excludeId != 'NULL ' ) {
52- $ query ->setParameter ($ idColumn , $ excludeId );
52+ $ query ->setParameter ($ this -> prepareParam ( $ idColumn) , $ excludeId );
5353 }
5454
5555 return $ query ->getSingleScalarResult ();
@@ -97,8 +97,8 @@ protected function select($collection)
9797 protected function queryExtraConditions (array $ extra , QueryBuilder $ builder )
9898 {
9999 foreach ($ extra as $ key => $ extraValue ) {
100- $ builder ->andWhere ("e. {$ key } = : { $ key}" );
101- $ builder ->setParameter ($ key , $ extraValue );
100+ $ builder ->andWhere ("e. {$ key } = : " . $ this -> prepareParam ( $ key) );
101+ $ builder ->setParameter ($ this -> prepareParam ( $ key) , $ extraValue );
102102 }
103103 }
104104
@@ -111,4 +111,14 @@ protected function getEntityManager($entity)
111111 {
112112 return $ this ->registry ->getManagerForClass ($ entity );
113113 }
114+
115+ /**
116+ * @param string $column
117+ *
118+ * @return string
119+ */
120+ protected function prepareParam ($ column )
121+ {
122+ return str_replace ('. ' , '' , $ column );
123+ }
114124}
0 commit comments