Welcome Guest, Not a member yet? Register   Sign In
wrong data from model
#1

[eluser]Todlerone[/eluser]
Hello all and TY in advance for any help/suggestions. I have used multiple table joins before but this one eludes me as to why it doesn't work. Here is a sample of two database queries from below.

array(2) {
[0]=>
array(13) {
["plan_status_id"]=>"576"
["plan_status_current"]=>"arc"
["plans_plan_name"]=>"plan1"
["treat_id"]=>"582"
["clinic_visit_id"]=>"426"
["treat_num"]=>"1"
["treat_region"]=>"Lung"
["treat_location"]=>"Middle"
["treat_loc_sagittal"]=>"Rt"
["treat_loc_axial"]=>NULL
["treat_loc_coronal"]=>NULL
["treat_dose"]=>"4800"
["treat_fractions"]=>"4"
}
[1]=>
array(13) {
["plan_status_id"]=>"577"
["plan_status_current"]=>"ip"
["plans_plan_name"]=>"Plan2"
["treat_id"]=>"583"
["clinic_visit_id"]=>"426"
["treat_num"]=>"2"
["treat_region"]=>"Lung"
["treat_location"]=>"Upper"
["treat_loc_sagittal"]=>"Lt"
["treat_loc_axial"]=>NULL
["treat_loc_coronal"]=>NULL
["treat_dose"]=>"4800"
["treat_fractions"]=>"4"
}
}

I'm trying to get the records of this person where the plan_status_current field is 'ip' only. Here is my model query

Code:
function auth_treatments($cv){
$this->db->select(' plan_status.plan_status_id,
     plan_status.plan_status_current,
     plan_status.plans_plan_name,
     treatments.treat_id,
     treatments.clinic_visit_id,
     treatments.treat_num,
      treatments.treat_region,
      treatments.treat_location,
     treatments.treat_loc_sagittal,
     treatments.treat_loc_axial,
     treatments.treat_loc_coronal,
      treatments.treat_dose,
      treatments.treat_fractions');
  $this->db->where('plan_status.clinic_visit_id', $cv);
  $this->db->where('plan_status.plan_status_current', 'ip');
  $this->db->join('treatments','plan_status.clinic_visit_id = treatments.clinic_visit_id');
  $this->db->from('plan_status');
  $query=$this->db->get('');
}

My results are mixed up and wrong.....Again thank-you.





Theme © iAndrew 2016 - Forum software by © MyBB