06-17-2011, 04:29 AM
[eluser]w1ntermut3[/eluser]
Several pages on a site I'm building will require 'share this' functionality; the user will be provided with a copy'n'paste shareable URL, or a URL will be posted to their Facebook wall, etc etc ad nauseum. For this, we'd like to generate unique tracking codes to append to the shared URL. Part of generating the tracking code is logging it to the database.
So, I've got to create a function that:
a) Will need to load - or at least, have access to - a DB model
b) Will be called by more than one controller
And I don't know where to put it. Putting identical copies into each controller class seems stupid; from what I understand, putting stuff that needs to load a database model into a helper class is also bad practice.
Where should this function go, in order to best fit the codeigniter MVC structure?
Several pages on a site I'm building will require 'share this' functionality; the user will be provided with a copy'n'paste shareable URL, or a URL will be posted to their Facebook wall, etc etc ad nauseum. For this, we'd like to generate unique tracking codes to append to the shared URL. Part of generating the tracking code is logging it to the database.
So, I've got to create a function that:
a) Will need to load - or at least, have access to - a DB model
b) Will be called by more than one controller
And I don't know where to put it. Putting identical copies into each controller class seems stupid; from what I understand, putting stuff that needs to load a database model into a helper class is also bad practice.
Where should this function go, in order to best fit the codeigniter MVC structure?