Welcome Guest, Not a member yet? Register   Sign In
Coming up with a business logic helper class
#12

[eluser]toopay[/eluser]
in your model, it should be...
Code:
function check_staff_on_leave()
{
      $this->db->select('Department, COUNT(*) AS on_leave', FALSE);
      $this->db->from('checkoff');
      $this->db->where('Department', $this->input->post('department'));
      $this->db->group_by('Department');
      $this->db->having('COUNT(*) >', 2);  
      $result = $this->db->get();
      if($result->num_rows() > 0)
      {
              $rows = $result->result_array();
              // Generating query to table 2
              $this->db->select('MIN(Date),StaffName,ReportBack');
              $this->db->from('appliedleaves');
              $this->db->where('Department', $rows[0]['Department']);
              $res = $this->db->get();
              // This variable should give you matched result from table 2
              $result = $res->result_array();
              
       }
       else
       {
              $result = 'No result';
       }  
       return $result;
}
then in your controller, you can use it like
Code:
...
$this->load->model('leave_model');
$data['staff'] = $this->leave_model->check_staff_on_leave();
$this->load->view('some_view',$data);
...
and in your 'some_view' file, you can check the result like...
Code:
...
<?php var_dump($staff); ?>
...


Messages In This Thread
Coming up with a business logic helper class - by El Forum - 04-07-2011, 06:54 AM
Coming up with a business logic helper class - by El Forum - 04-07-2011, 10:22 PM
Coming up with a business logic helper class - by El Forum - 04-07-2011, 11:41 PM
Coming up with a business logic helper class - by El Forum - 04-07-2011, 11:53 PM
Coming up with a business logic helper class - by El Forum - 04-08-2011, 03:17 AM
Coming up with a business logic helper class - by El Forum - 04-08-2011, 10:34 AM
Coming up with a business logic helper class - by El Forum - 04-10-2011, 11:13 PM
Coming up with a business logic helper class - by El Forum - 04-10-2011, 11:45 PM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 01:25 AM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 01:45 AM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 05:58 AM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 06:11 AM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 06:24 AM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 06:36 AM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 06:43 AM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 06:56 AM
Coming up with a business logic helper class - by El Forum - 04-11-2011, 07:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB