2016-11-04 5 views
-1

나는이 작업을 수행하는 데 도움이되는 것은 무엇입니까?

function get_debtors() { 

    $this->db->select('invoice.student_id as STUDENT_ID,student.name AS 
         STUDENT_NAME,section.name AS CLASS, 
         invoice.description AS DESCRIPTION, 
         invoice.amount AS TOTAL_AMOUNT, 
         invoice.amount_owed AS AMOUNT_OWED, 
         parent.name AS PARENT_NAME, 
         parent.email AS PARENT_EMAIL, 
         parent.phone AS PARENT_PHONE, 
         parent.address AS PARENT_ADDRESS, 
         invoice.status AS STATUS'); 

    $this->db->from('invoice , student , parent , section '); 

    $this->db->join('student ', 'student.student_id = invoice.student_id'); 

    $this->db->join('parent ', 'parent.parent_id = student.parent_id, 'left''); 

    $this->db->join('section ', 'section.section_id = student.section_id','left'); 

    $this->db->where('invoice.status', 'debtor'); 

    $query = $this->db->get(); 
+0

당신은 '이 라인'에 left'''후'인용 $ this-> DB-> (가입'여분의 하나를 '사용 부모', 'parent.parent_id = student.parent_id,'왼쪽 ''); ' –

+0

에서 송장 테이블 만 사용하십시오. $ this-> db-> from ('invoice '); 조건에 따라 다른 테이블이 조인됩니다. – hrishi

답변

0

이 시도 구축 내가 쿼리에 가입해야 네 개의 테이블이있다. 여전히 오류가있는 경우 여기에 오류를 게시하십시오.

function get_debtors() 
{ 

    $this->db->select('invoice.student_id as STUDENT_ID,student.name AS 
         STUDENT_NAME,section.name AS CLASS, 
         invoice.description AS DESCRIPTION, 
         invoice.amount AS TOTAL_AMOUNT, 
         invoice.amount_owed AS AMOUNT_OWED, 
         parent.name AS PARENT_NAME, 
         parent.email AS PARENT_EMAIL, 
         parent.phone AS PARENT_PHONE, 
         parent.address AS PARENT_ADDRESS, 
         invoice.status AS STATUS'); 

    $this->db->from('invoice'); 

    $this->db->join('student ', 'student.student_id = invoice.student_id'); 

    $this->db->join('parent ', 'parent.parent_id = student.parent_id', 'left'); 

    $this->db->join('section ', 'section.section_id = student.section_id','left'); 

    $this->db->where('invoice.status', 'debtor'); 

    $query = $this->db->get(); 
} 
관련 문제