1

我有这样的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活动记录?

4

2 回答 2

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();
于 2013-01-04T03:13:58.580 回答
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 *”

于 2013-01-04T06:41:43.490 回答