Data Mapper Pattern: Complexe query from Service Layer

前端 未结 2 1518
梦毁少年i
梦毁少年i 2021-02-08 20:35

I\'m sing the Data Mapper Pattern in Zend Framework. This works well so far, but now I got to a point where I need your help/opinion. So let\'s start with the Code:

We g

2条回答
  •  离开以前
    2021-02-08 20:57

    Indeed, for two conditions, it inadvisable to query on one condition and then filter on your other while you iterate. It leaves you no clear approach for more than two conditions. And implementing pagination adapters becomes pretty messy.

    Seems to me that the issue is that your mapper fetch() method supports permits only a single condition. So:

    1. Modify the signature to support an array of conditions.

    2. Alternatively, you could create a separate mapper method for each enhanced fetch method, ex: fetchByHairAndAge($hair, $age), etc.

提交回复
热议问题