我有这样的mysql查询:
SELECT * FROM ms_project_log
INNER JOIN ms_project ON ms_project_log.iwo_no = ms_project.iwo_no
WHERE ms_project_log.iwo_no = '0007/NMS/BOTM/01/12'
ORDER BY ms_project_log.log_date DESC
如何转换为codeigniter活动记录?
答案 0 :(得分:1)
这是给你的代码
$this->db->select('*');
$this->db->from('ms_project_log');
$this->db->join('ms_project','ms_project_log.iwo_no=ms_project_iwo_no', 'inner');
$this->db->where(ms_project_log.iwo_no, '0007/NMS/BOTM/01/12');
$this->db->order_by("ms_project_log.log_date", "desc");
$this->db->get();
答案 1 :(得分:0)
$this->db->join('ms_project','ms_project_log.iwo_no = ms_project.iwo_no','inner')
->order_by('ms_project_log.log_date','desc')
->get_where('ms_project_log', array('ms_project_log.iwo_no'=>'0007/NMS/BOTM/01/12'))
->result_array();
您可以使用select方法过滤所选列,默认情况下,如果不使用select方法,您的查询将使用“select *”