Welcome Guest, Not a member yet? Register   Sign In
Model/Controller Quick Question
#3

[eluser]Christopher Blankenship[/eluser]
Ok. putting my two cents into the mix.

Here is what I like to do to avoid all those $_POST statements.
Code:
/* controller: add_task */
   $this->load->helper('form');
   $data = array('title' => "Add Task");
   $data['pid'] = $this->uri->segment(3);
   $this->load->view('add_task', $data);

/* view: add_task  */
   echo form_open('welcome/add_task_rec');
   echo form_hidden('rec[pid]', "$pid");
   echo form_textarea('rec[notes]', '');
   echo form_submit('Submit', 'Submit');

/* controller: add_task_rec
* this however could be separated out to the model
* if so wished but the point is to pass all the information
* as an array to avoid the $_POST groups.
*/
   $this->db->insert('ticket', $_POST['rec']);
   redirect("$base_url");
That should at least shorten your coding efforts and help with cleaner code. The code is just an example and I assume you have already gone to application/config/autoload.php and set the following:
Code:
$autoload['libraries'] = array('database');


Messages In This Thread
Model/Controller Quick Question - by El Forum - 07-02-2007, 04:21 PM
Model/Controller Quick Question - by El Forum - 07-02-2007, 04:49 PM
Model/Controller Quick Question - by El Forum - 07-02-2007, 05:28 PM
Model/Controller Quick Question - by El Forum - 07-03-2007, 02:18 AM
Model/Controller Quick Question - by El Forum - 07-03-2007, 11:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB