I want to create a Advance Search, something like this:
What is the proper way to add those parameters in the function for the model?
I have came up with this solution:
class ShopsModel extends Model {
findBy($find, $searchBy, $order, $sort, $betweenDate) {
// some MySQL query here...
}
}
Edit: I am talking about the variables - findBy($find, $searchBy, $order, $sort, $betweenDate)
- do I need all those parameters or is there alternative solution?
Your solution seems to be ok. But you can also use decorator pattern, so you could make the following query:
$shops = new ShopsModel();
$results = $shops->search('name', 'Tadeck')
->order_by('name', 'asc')
->between_dates('2012-02-01', '2012-03-14')
->fetch_all();