加入活跃的记录codeigniter

时间:2017-11-25 18:55:47

标签: php codeigniter join activerecord

你想帮助我吗?如何将此sql查询更改为codeigniter中的活动记录

LEFT JOIN MGMETADATA.services d ON d.protocol = e.protocol and d.port = e.s_port

谢谢,

2 个答案:

答案 0 :(得分:1)

请试试这个

$this->db->select('*');
$this->db->from('tableE');
$this->db->join('tableD','tableD.protocol=tableE.protocol and tableD.port=tableE.s_port','left');
$query = $this->db->get();
return $query->result();

我希望这可以帮到你

答案 1 :(得分:0)

$this->db->select("*")
         ->join("MGMETADATA.services as d","d.protocol = e.protocol","left")
         ->where("d.port = e.s_port")
         ->get("tablename e")
         ->result(); //for json format 

注意:不要使用" *"要选择所有列,请使用单个列名进行检索。

相关问题