2 回答

TA貢獻1848條經驗 獲得超10個贊
要使用 CI 生成完整的查詢字符串,您需要添加以下行:
$query=$db->get();你的方法。
完整的代碼如下所示:
$this->db->select('m.*,c.COUNTRY_NAME');
$this->db->from('members m');
$this->db->join('country c','c.COUNTRY_ALPHA2_CODE = m.location', 'left');
$this->db->where('c.LANG', 'EN');
$query=$db->get();
在此行之后,您可以使用以下命令檢查 SQL 字符串輸出:
echo $this->db->query();
從這里您可以繼續為您的視圖生成查詢結果
回復評論:
'$this->db->where('c.LANG', 'EN');'不起作用。此行始終返回數據庫中的第一語言
您需要將語言查詢放入連接中:
$this->db->select('m.*,c.COUNTRY_NAME');
$this->db->from('members m');
$this->db->join('country c','(c.COUNTRY_ALPHA2_CODE = m.location AND c.LANG=\'EN\')', 'left');
$query=$db->get();

TA貢獻1831條經驗 獲得超4個贊
試試這個:
$this->db->select('m.*');
$this->db->select('c.COUNTRY_NAME');
$this->db->from('members m');
$this->db->join('country c','c.COUNTRY_ALPHA2_CODE = m.location', 'left');
$this->db->where('c.LANG', 'EN');
- 2 回答
- 0 關注
- 104 瀏覽
添加回答
舉報