load->model('PD_Model'); //return ( $CI->PD_Model->selectCustomRecords(array('pd_co_applicant_id','applicant_name'),array('fk_pd_id' => $pd_id),PDAPPLICANTSDETAILS)); $columns = array('pd_co_applicant_id','applicant_name','TITLES.name as title'); $table = array(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS'); $joins = array( array('table' => TITLES. ' as TITLES', 'condition' =>"PDAPPLICANTSDETAILS.applicant_title_name = TITLES.title_id AND PDAPPLICANTSDETAILS.fk_pd_id = $pd_id", 'jointype' => 'LEFT') ); return ( $CI->PD_Model->getJoinRecords($columns,$table,$joins)); } public static function getApplicantsNameById($id,$latest_applicants_names,$type = 1) //$type i for return name only, 2 for return title only, and 3 for return both { foreach ($latest_applicants_names as $key => $value) { if($id == $value['pd_co_applicant_id']) { return $type == 1 ? $value['applicant_name'] : ($type == 2 ? $value['title'] : ($value['title'].' '.$value['applicant_name'])); } } } public static function getMultipleApplicantsNameById($arr,$latest_applicants_names) //$type i for return name only, 2 for return title only, and 3 for return both { $mergered_applicants_name = ''; foreach ($arr as $key => $value) { foreach ($latest_applicants_names as $k => $val) { if($value == $val['pd_co_applicant_id']) { $mergered_applicants_name .= $val['applicant_name'].', '; } } } if($mergered_applicants_name != ''){ $mergered_applicants_name = substr_replace($mergered_applicants_name, '',-2);} return $mergered_applicants_name; } } ?>