Extending table functions |
[eluser]starsinmypockets[/eluser]
I built the following function to dynamically build a table from db values. Code: function make_table($table = '', $fields = array(), $link = '') I like what this does, and how it does it, but I have a couple questions: 1. Where should this live so that I can access it from all of my controllers? 2. Should I separate out the db calls for semantic reasons?
[eluser]InsiteFX[/eluser]
MY_Controller and extend your other Controllers from the MY_Controller InsiteFX
[eluser]JonoB[/eluser]
I'd suggest making a library (http://ellislab.com/codeigniter/user-gui...aries.html) or (if it only contains one function) then a helper would probably be OK too.
[eluser]starsinmypockets[/eluser]
Is it acceptable to call other class methods from within library/helper functions - for instance, Code: $this->table->set_heading('foo');
[eluser]JonoB[/eluser]
[quote author="starsinmypockets" date="1307901587"]Is it acceptable to call other class methods from within library/helper functions - for instance, Code: $this->table->set_heading('foo'); Read the section in the above help document Quote:Utilizing CodeIgniter Resources within Your Library
[eluser]InsiteFX[/eluser]
Or you can extend the Table Class and add your new method to it! InsiteFX |
Welcome Guest, Not a member yet? Register Sign In |