如何将sql查询转换为codeigniter活动记录?

时间:2018-02-10 06:16:54

标签: php sql codeigniter

SELECT a.*,e.* FROM `hierarchy_users` AS a
INNER JOIN `enquiry` As e
ON (e.hierarchy_users_id=a.id AND e.`enquiry_date`='2018-02-2')
WHERE `created_by`='31'

1 个答案:

答案 0 :(得分:1)

试试这个

$this->db->select('a.*,e.*');
$this->db->from('hierarchy_users a');
$this->db->join('enquiry e','e.hierarchy_users_id=a.id');
$this->db->where('e.enquiry_date=2018-02-02');
$result_set = $this->db->get();
if($result_set->num_rows() > 0){
   return $result_set->result();
}