2016-03-15 27 views
0

我想通過使用codeigniter的活動記錄從表中獲取具有一些外鍵的數據。我沒有得到任何結果。我的問題是我要錯的地方是我的模型代碼。Codeigniter中的條件

public function fetch_customer() 
    { 
     $s = 'customer.stb_id'; 
     $w_array = array('set_top_box.stb_id' => $s); 
     $customers = $this->db->select('customer.c_name,customer.acc_no,customer.stb_id,set_top_box.stb_no,customer.mobile_no,customer.subscription_amount,customer.c_status') 
           ->from('customer,set_top_box') 
           ->where($w_array) 
           ->get(); 
      return $customers->result(); 
    } 
+0

條款你不能在'從()'你應該使用'多個表加入()'爲此。例如('customer c'); $ this-> db-> join('set_top_box stb','stb.stb_no = c.stb_id')' – AdrienXL

+0

可以使用多於一個從()AdrienXL –

回答

1

你好,你不能在窗體中添加多個表名()使用join()方法是這樣

public function fetch_customer() 
    { 
     $s = 'customer.stb_id'; 
     $w_array = array('set_top_box.stb_id' => $s); 
     $customers = $this->db->select('customer.c_name,customer.acc_no,customer.stb_id,set_top_box.stb_no,customer.mobile_no,customer.subscription_amount,customer.c_status') 
           ->from('customer') 
           ->join('set_top_box','here on clause ') 
           ->where($w_array) 
           ->get(); 
      return $customers->result(); 
    } 
+0

謝謝你的答案@Divyesh。這是獲取數據的正確方法。你的郵件ID是什麼?即時消息從艾哈邁達巴德也。 –

+0

[email protected] – Divyesh