I am working on reports page for a ZF2 project. Now I need to generate dynamic query depends on filters (which can be ‘=’, ‘>’, ‘>=’, ‘<‘, ‘<=’, ‘IN’ ). I am using DB select closure for generate where statement. But I am afraid if it could be a bottleneck in coming days ( by performance or by limitations ).
Can any body suggest if my approach is Ok or need to generate string where statements like
->where('A > 12 AND B < 12 AND C IN (1,2,3)')
instead of
->where(function(Where $where){
$where->equalTo('A', 10)->equalTo('B', 12)->IN('C', array(1,2,3));
});
Or any better idea ?
I got a better solution. Instead of using closure I using direct Where Object something like that
It is more dynamic as $where can be dynamically updated by other values. Still if anybody have other ideas please share.