【问题标题】:join in active record codeigniter加入活动记录codeigniter
【发布时间】:2023-03-14 06:36:02
【问题描述】:

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

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

谢谢,

【问题讨论】:

  • 这是您的完整查询吗?

标签: php codeigniter join activerecord


【解决方案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();

希望对你有帮助

【讨论】:

    【解决方案2】:
    $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 
    

    注意:不要使用“*”来选择所有列,请使用单个列名来检索。

    【讨论】:

      猜你喜欢
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-22
      相关资源
      最近更新 更多