The code below works, allowing me to retrieve all fields for a single record. One of the fields I use from this record is 'name' but to access it on the view page, I must place two lines of code to extract the 'name' field from the record returned. I want to be able to extract the 'name' field in the controller and pass to view. I'm sure there is a simply solution since the data is already successfully retrieved.
MODEL - Performs a select all and returns a single record
// Select a record (all columns) from 'proposal_info' table per prop ID
public function
get_propinfo($propid) {
// Build query
$this->db->select('*');
$this->db->from('proposal_info P');
$this->db->join('status', 'P.status = status.id');
$this->db->join('regions', 'P.region = regions.id');
$this->db->join('usa_states', 'P.state_id = usa_states.id');
$this->db->join('type', 'P.type = type.id');
$this->db->where('P.id', $propid);
return $this->db->get();
}
CONTROLLER - The line in red is is where I retrieve the record from the query in the model. The 'name' field is contained within the $data['propinfo'] but how can I retrieve it here in the controller? Seems like it would
public function summary() {
$this->load->model('Propinfo_model');
$data['page'] = "Project Summary";
$data['allprops'] = $this->Propinfo_model->get_allprops($_SESSION['userid_db']); // required for LH nav proj list
$data['propinfo'] = $this->Propinfo_model->get_propinfo($_SESSION['session_propid']); // query for proposal info
$data['announcements'] = $this->Propinfo_model->get_announcements($_SESSION['session_propid']); // query for announcements
$this->load->view('templates/bp_header_view', $data);
$this->load->view('templates/bp_nav_view', $data);
$this->load->view('summary_view', $data); // page content
$this->load->view('templates/bp_footer_view', $data);
$this->load->view('templates/bp_endjs_view', $data);
}
VIEW - Unfortunately, this is the only way I know how to get the 'name' field. This wks, but I want to do this at the controller, not the view.
$row = $propinfo->row_array();
$proposal_name = $row['name'];
Any feedback is greatly appreciated.