New to MVC/Codeigniter and still don't completely understand all the concepts. I hope my question was somewhat clear but here is what I'm trying to do:
My application is basically a multipage form that the user fills out and at the end has a report he can view based on all of his inputs. Report flow is basically like this
'Create New Report' -> 'fill customer info' -> 'fill user info' -> 'Enter Data' -> 'Preview Report'
All steps above are essentially views and have corresponding controllers and models.
Every time a new report is created I insert a row with new report id in my db using my reports controller:
class Reports extends CI_Controller { public function index() { //list all current existing reports //model controller simple get to return all reports in db $data['results'] = $this->report_model->get_reports(); $this->load->view('header'); $this->load->view('reports_view', $data); $this->load->view('footer'); } public function createReport() { //create new id for report when user initiates new report //Enter placeholders in reports db until further info recieved $data = array( 'customer_id' => 1, 'user_id' => 1, 'data_id' => 1 ); //will be done in model just temporarily in controller $this->db->insert('reports', $data); } }When selected 'Create New Report' will take you to the 'fill customer info' view which is a simple form with name, contact etc. The customer controller and model will store information to customer db and create new id for the customer.
Customer Controller:
class Customer extends CI_Controller {
public $customerData;
public function index()
{
$this->load->view('header');
$this->load->view('customer_view');
$this->load->view('footer');
}
public function saveCustomerInfo() {
$customerData = array(
'customerName' => $this->input->post('customer_name'),
'customerPhone' => $this->input->post('customer_phne'),
'customerEmail' => $this->input->post('customer_email'),
'customerAddress' => $this->input->post('customer_addr'),
'customerCity' => $this->input->post('customer_city'),
'customerstate' => $this->input->post('customer_state')
);
$output = $this->customer_model->save_customers($customerData);
}
}
- I have done the same thing with the next two view as well.
All the info from customer, user, and data is linked to my Report table through primary key in the other tables to Reports table looks essentially like this.
*---------------------------------------------------------*
| report_id | (fk)customer_id | (fk)user_id | (fd)data_id |
*---------------------------------------------------------*
| 1 | 4 | 7 | 3 |
| 2 | 2 | 9 | 1 |
| 3 | 1 | 1 | 6 |
I want to know how do I store the $report_id for the current report in progress so that I can pass it to customer/user/data controller so as those parts of the form are filled out and being written to the db I can update the reports table and replace the placeholders I had initially with the current customer, user and data information.
I don't quite want to sue sessions for this so is what is the best way to do this. Might be a really simple answer but I'm a newb so help would be much appreciated.
$_SESSION?