我正在使用CodeIgniter。下面的代码,我在模型中使用。
我的问题是,我必须显示联接的输出,同时我还要在If条件中使用另一个条件。
我正在做的是,我正在从多个表中获取记录,并在IF条件中传递membershipForTheYear
列名。
membershipForTheYear output is the year range like 2018-2019.
我正在使用explode打破它,并将其从2018-2019更改为2019-2020以从表中获取输出。现在,我必须显示this的输出并加入视图。
为什么要这样做,因为我必须显示上述联接输出的下一年费用。
我应该返回两个结果还是必须使用一些数组?
您能帮我吗?
public function upcomingData(){
$get_s_member = array('members.is_Approved'=>1,'members.is_status'=>1);
$this->db->select('*');
$this->db->from('members');
$this->db->join('membership_details', 'members.member_id = membership_details.member_id','LEFT');
$this->db->where($get_s_member);
$this->db->group_by('membership_details.member_id');
$this->db->order_by('membership_details.membership_added_date','DESC');
$query = $this->db->get();
$result = $query->result();
if($result)
{
foreach ($result as $key => $value) {
$membershipForTheYear=explode('-',$value->membershipForTheYear);
$addNextyear=$membershipForTheYear[1] + 1;
$activeBTN=$membershipForTheYear[1].'-'.$addNextyear;
$where = array('Duration'=>$activeBTN,'is_FeesActive'=>1);
$result = $this->db->where($where)
->from('bMembershipFees')
->get()
->row();
// print_r($result);
}
return $result;
}
else
{
return 0;
}
}
答案 0 :(得分:0)
public function upcomingData() {
$respose_array = array();
$get_s_member = array('members.is_Approved' => 1, 'members.is_status' => 1);
$this->db->select('*');
$this->db->from('members');
$this->db->join('membership_details', 'members.member_id = membership_details.member_id', 'LEFT');
$this->db->where($get_s_member);
$this->db->group_by('membership_details.member_id');
$this->db->order_by('membership_details.membership_added_date', 'DESC');
$query = $this->db->get();
$result = $query->result();
if ($result) {
foreach ($result as $key => $value) {
$membershipForTheYear = explode('-', $value->membershipForTheYear);
$addNextyear = $membershipForTheYear[1] + 1;
$activeBTN = $membershipForTheYear[1] . '-' . $addNextyear;
$where = array('Duration' => $activeBTN, 'is_FeesActive' => 1);
$result1 = $this->db->where($where)
->from('bMembershipFees')
->get()
->row();
// print_r($result);
}
$respose_array[0] = $result;
$respose_array[1] = $result1;
return $respose_array;
} else {
return $respose_array = array(0=>'0',1=>'0');
}
}