Codeigniter - Is it ok to add functionality to the constructor in controllers?
- by Irro
I'm making a project where I want the user to search for shops in different cities and would like the url to be like this: domain/shop/city/name.
So I created a controller in codeigniter called Shop. But I cant create a city function since the city part of the url changes dependent on city name. One easy way to do it would be to add a function called "search" and add the functionality there but then I get url's like: domain/shop/search/city/name which I really would like to avoid.
So my question is if it's ok to add my functionality directly into the constructor to avoid that extra "search" part in the url? I'm afraid that there might be some performance tricks involved that potentially keeps the class in memory so the constructor will not be called every time.