@@ -117,74 +117,78 @@ protected function attachDynamicFields(array $aData,$oObject) {
117117 public function fetchAll ($ bPaginated = false ,$ aWhere = [],$ sSort = 'created_date DESC ' ,$ iLimit = 0 ) {
118118 $ oSel = new Select ($ this ->oTableGateway ->getTable ());
119119
120- # Build where
121- $ oWh = new Where ();
122- foreach (array_keys ($ aWhere ) as $ sWh ) {
123- $ bIsLike = stripos ($ sWh ,'-like ' );
124- if ($ bIsLike === false ) {
125-
126- } else {
127- # its a like
128- $ oWh ->like (substr ($ sWh ,0 ,strlen ($ sWh )-strlen ('-like ' )),$ aWhere [$ sWh ].'% ' );
129- }
120+ if (is_object ($ aWhere )) {
121+ $ oSel ->where ($ aWhere );
122+ } else {
123+ # Build where
124+ $ oWh = new Where ();
125+ foreach (array_keys ($ aWhere ) as $ sWh ) {
126+ $ bIsLike = stripos ($ sWh ,'-like ' );
127+ if ($ bIsLike === false ) {
128+
129+ } else {
130+ # its a like
131+ $ oWh ->like (substr ($ sWh ,0 ,strlen ($ sWh )-strlen ('-like ' )),$ aWhere [$ sWh ].'% ' );
132+ }
130133
131- $ bIsLike = stripos ($ sWh ,'-lkall ' );
132- if ($ bIsLike === false ) {
134+ $ bIsLike = stripos ($ sWh ,'-lkall ' );
135+ if ($ bIsLike === false ) {
133136
134- } else {
135- # its a like
136- $ oWh ->like (substr ($ sWh ,0 ,strlen ($ sWh )-strlen ('-lkall ' )),'% ' .$ aWhere [$ sWh ].'% ' );
137- }
137+ } else {
138+ # its a like
139+ $ oWh ->like (substr ($ sWh ,0 ,strlen ($ sWh )-strlen ('-lkall ' )),'% ' .$ aWhere [$ sWh ].'% ' );
140+ }
138141
139- $ bIsIDFS = stripos ($ sWh ,'_idfs ' );
140- if ($ bIsIDFS === false ) {
142+ $ bIsIDFS = stripos ($ sWh ,'_idfs ' );
143+ if ($ bIsIDFS === false ) {
141144
142- } else {
143- # its a like
144- $ oWh ->equalTo ($ sWh ,$ aWhere [$ sWh ]);
145- }
145+ } else {
146+ # its a like
147+ $ oWh ->equalTo ($ sWh ,$ aWhere [$ sWh ]);
148+ }
146149
147- $ bIsGreaterEqual = stripos ($ sWh ,'-greaterthanequalto ' );
148- if ($ bIsGreaterEqual === false ) {
150+ $ bIsGreaterEqual = stripos ($ sWh ,'-greaterthanequalto ' );
151+ if ($ bIsGreaterEqual === false ) {
149152
150- } else {
151- # its a like
152- $ oWh ->greaterThanOrEqualTo (substr ($ sWh ,0 ,strlen ($ sWh )-strlen ('-greaterthanequalto ' )),$ aWhere [$ sWh ]);
153- }
153+ } else {
154+ # its a like
155+ $ oWh ->greaterThanOrEqualTo (substr ($ sWh ,0 ,strlen ($ sWh )-strlen ('-greaterthanequalto ' )),$ aWhere [$ sWh ]);
156+ }
154157
155- $ bIsLessEqual = stripos ($ sWh ,'-lessthanequalto ' );
156- if ($ bIsLessEqual === false ) {
158+ $ bIsLessEqual = stripos ($ sWh ,'-lessthanequalto ' );
159+ if ($ bIsLessEqual === false ) {
157160
158- } else {
159- # its a like
160- $ oWh ->lessThanOrEqualTo (substr ($ sWh ,0 ,strlen ($ sWh )-strlen ('-lessthanequalto ' )),$ aWhere [$ sWh ]);
161+ } else {
162+ # its a like
163+ $ oWh ->lessThanOrEqualTo (substr ($ sWh ,0 ,strlen ($ sWh )-strlen ('-lessthanequalto ' )),$ aWhere [$ sWh ]);
164+ }
161165 }
166+ if (array_key_exists ('created_by ' ,$ aWhere )) {
167+ $ oWh ->equalTo ('created_by ' ,$ aWhere ['created_by ' ]);
168+ }
169+ if (array_key_exists ('modified_by ' ,$ aWhere )) {
170+ $ oWh ->equalTo ('modified_by ' ,$ aWhere ['modified_by ' ]);
171+ }
172+ if (array_key_exists ('multi_tag ' ,$ aWhere )) {
173+ $ sEntityType = explode ('- ' ,$ this ->sSingleForm )[0 ];
174+ $ oSel ->join (['category_tag ' =>'core_entity_tag_entity ' ],'category_tag.entity_idfs = ' .$ sEntityType .'. ' .ucfirst ($ sEntityType ).'_ID ' );
175+ $ oWh ->equalTo ('category_tag.entity_tag_idfs ' ,$ aWhere ['multi_tag ' ]);
176+ $ oWh ->like ('category_tag.entity_type ' ,explode ('- ' ,$ this ->sSingleForm )[0 ]);
177+ }
178+ if (array_key_exists ('multi_tag_custom ' ,$ aWhere )) {
179+ $ sEntityType = explode ('- ' ,$ this ->sSingleForm )[0 ];
180+ $ oSel ->join (['category_tag_custom ' =>$ aWhere ['multi_tag_custom-tbl ' ]],'category_tag_custom. ' .$ aWhere ['multi_tag_custom-keyjoin ' ].' = ' .$ sEntityType .'. ' .ucfirst ($ sEntityType ).'_ID ' );
181+ $ oWh ->equalTo ('category_tag_custom. ' .$ aWhere ['multi_tag_custom-keylike ' ],$ aWhere ['multi_tag_custom ' ]);
182+ }
183+ if (array_key_exists ('tag_like ' ,$ aWhere )) {
184+ $ sEntityType = explode ('- ' ,$ this ->sSingleForm )[0 ];
185+ $ oSel ->join (['category_tag ' =>'core_entity_tag_entity ' ],'category_tag.entity_idfs = ' .$ sEntityType .'. ' .ucfirst ($ sEntityType ).'_ID ' );
186+ $ oSel ->join (['entity_tag ' => 'core_entity_tag ' ],'entity_tag.Entitytag_ID = category_tag.entity_tag_idfs ' ,['Entitytag_ID ' ,'tag_value ' ,'tag_idfs ' ]);
187+ $ oWh ->like ('entity_tag.tag_value ' ,'% ' .$ aWhere ['tag_like ' ].'% ' );
188+ //$oWh->like('category_tag.entity_type',explode('-',$this->sSingleForm)[0]);
189+ }
190+ $ oSel ->where ($ oWh );
162191 }
163- if (array_key_exists ('created_by ' ,$ aWhere )) {
164- $ oWh ->equalTo ('created_by ' ,$ aWhere ['created_by ' ]);
165- }
166- if (array_key_exists ('modified_by ' ,$ aWhere )) {
167- $ oWh ->equalTo ('modified_by ' ,$ aWhere ['modified_by ' ]);
168- }
169- if (array_key_exists ('multi_tag ' ,$ aWhere )) {
170- $ sEntityType = explode ('- ' ,$ this ->sSingleForm )[0 ];
171- $ oSel ->join (['category_tag ' =>'core_entity_tag_entity ' ],'category_tag.entity_idfs = ' .$ sEntityType .'. ' .ucfirst ($ sEntityType ).'_ID ' );
172- $ oWh ->equalTo ('category_tag.entity_tag_idfs ' ,$ aWhere ['multi_tag ' ]);
173- $ oWh ->like ('category_tag.entity_type ' ,explode ('- ' ,$ this ->sSingleForm )[0 ]);
174- }
175- if (array_key_exists ('multi_tag_custom ' ,$ aWhere )) {
176- $ sEntityType = explode ('- ' ,$ this ->sSingleForm )[0 ];
177- $ oSel ->join (['category_tag_custom ' =>$ aWhere ['multi_tag_custom-tbl ' ]],'category_tag_custom. ' .$ aWhere ['multi_tag_custom-keyjoin ' ].' = ' .$ sEntityType .'. ' .ucfirst ($ sEntityType ).'_ID ' );
178- $ oWh ->equalTo ('category_tag_custom. ' .$ aWhere ['multi_tag_custom-keylike ' ],$ aWhere ['multi_tag_custom ' ]);
179- }
180- if (array_key_exists ('tag_like ' ,$ aWhere )) {
181- $ sEntityType = explode ('- ' ,$ this ->sSingleForm )[0 ];
182- $ oSel ->join (['category_tag ' =>'core_entity_tag_entity ' ],'category_tag.entity_idfs = ' .$ sEntityType .'. ' .ucfirst ($ sEntityType ).'_ID ' );
183- $ oSel ->join (['entity_tag ' => 'core_entity_tag ' ],'entity_tag.Entitytag_ID = category_tag.entity_tag_idfs ' ,['Entitytag_ID ' ,'tag_value ' ,'tag_idfs ' ]);
184- $ oWh ->like ('entity_tag.tag_value ' ,'% ' .$ aWhere ['tag_like ' ].'% ' );
185- //$oWh->like('category_tag.entity_type',explode('-',$this->sSingleForm)[0]);
186- }
187- $ oSel ->where ($ oWh );
188192 $ oSel ->order ($ sSort );
189193
190194 if ($ iLimit != 0 ) {
0 commit comments