[eluser]Dani[/eluser]
Hello, I've recently started to learn CI to get more tidy code and less code repeating. Seems I repeat code too much. I'm creating a site for administrating clubs. F.ex. now I need two methods called get_all_clubs() in my club_model that does almost the same. They could be called f.ex. get_all_clubs1() and get_all_clubs2();
First method returns a 2-dim array and is for listing all clubs in the clubs index page. The second returns a 1-dim array and is used for adding all clubs to a <select>-list.
When I try to merge these two methods, it seems I need the <form> in the view to send a hidden value, which the controller then tests to see if checked, and then sends that flag as a parameter to the method which in turn checks if the parameter flag is checked and then uses a if() and generates the 1-dim version if it's set. This second approach easily becomes messy code, but it's also a little less code repeating. So what's the way to go?
I have other similar questions too, but I take this one first