![]() |
db stuff - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: db stuff (/showthread.php?tid=26237) |
db stuff - El Forum - 01-09-2010 [eluser]sasori[/eluser] is it mandatory to create a function first on the controller before being allowed to execute an insert or any db stuff queries? :question: e.g I loaded the $this->load->database() from the constructor and then at the bottom I did these, Code: $data = array( then when I wrapped those query inside a function and it worked :gulp: db stuff - El Forum - 01-09-2010 [eluser]Jamie Rumbelow[/eluser] A T_FUNCTION error is a syntax error - are you sure your syntax is correct? You should be able to directly query out of a controller function, but by the Model-View-Controller convention you should put any data-related functionality in the Model. Jamie db stuff - El Forum - 01-09-2010 [eluser]JHackamack[/eluser] You should create a function on the controller first (such as index) so CI knows what to display by default. |