Welcome Guest, Not a member yet? Register   Sign In
Code Committing Help/Advice
#1

[eluser]Unknown[/eluser]
So, I would say that I am pretty new to CI. Been using it for a couple of months and only have been coding for 2 years. Since I am still so new and have mainly worked on really small "local" projects and ideas I am starting to feel a bit uncomfortable with the amount of comments I have placed within my first large project. So, to see what I mean, let me give you an small example of a method from a controller...

Code:
public function mileage_submit(){
  /* Load any helpers for this page */
  $this->load->helper('form');

  /* Load any models need for this page */
  $this->load->model('user'); //used for retrieving user name using CI_SESSION Data
  $this->load->model('mileage'); // Holds the queries for mileage log entries

  //Load data variables for this page
  $data['title'] = "Rayco Mileage Log";
  $data['css'] = base_url('/css/style.css'); // Loads the correct stylesheet for the page
  $submit = $this->input->post('submit'); //used to check if submit button was pressed.
  $date = $this->input->post('start'); //used to check if a starting od was entered.
  $end = $this->input->post('end'); // used to check if a ending od was entered.
  $name = $this->user->getName(); // gets the logged in users full name

  /* When clicking the submit button, pass the $_POST data to the model */
  if($submit == TRUE && $end == FALSE){
   $q = $this->mileage->full(
     $this->user->getName(),
     $this->input->post('date', TRUE),
     $this->input->post('start', TRUE),
     $this->input->post('end', TRUE),
     $this->input->post('notes', TRUE)
     );
   }else{
   $q = $this->mileage->update(
     $this->user->getName(),
     $this->input->post('date', TRUE),
     $this->input->post('end', TRUE),
     $this->input->post('notes', TRUE)
     );
  }

  /* Load the files needed for the view */
  $this->load->view('includes/head', $data);
  $this->load->view('includes/header');
  $this->load->view('mileage_submit');
  $this->load->view('includes/footer');
}

I'm sure there is a way I can improve this or neaten it up. What are your suggestions?


Messages In This Thread
Code Committing Help/Advice - by El Forum - 11-20-2012, 07:14 PM
Code Committing Help/Advice - by El Forum - 11-20-2012, 10:44 PM
Code Committing Help/Advice - by El Forum - 11-20-2012, 10:46 PM
Code Committing Help/Advice - by El Forum - 11-20-2012, 11:36 PM
Code Committing Help/Advice - by El Forum - 11-21-2012, 05:47 AM
Code Committing Help/Advice - by El Forum - 11-21-2012, 06:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB