2016-11-04 8 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

あなたが親を余分に1つの ' ''この行のleft''は 'ます$ this-> DB->(参加後に'引用' を使用」、 'parent.parent_id = student.parent_id、 '左'' ); ' –

+0

$ this-> db-> from(' invoice ')のインボイステーブルのみを使用します。他のテーブルは条件ごとに結合されます – hrishi

答えて

0

を構築し、クエリに参加する必要がある4つのテーブルを持っているが、これを試してみてください。まだエラーがある場合は、ここにもエラーを投稿してください。

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(); 
} 
関連する問題