如何将此查询转换为Codeigniter活动记录

时间:2013-01-16 06:12:10

标签: mysql codeigniter

SELECT 
    case_id,
    serialnumber,
    DateLastHere,
    Bookedindate,
    DATEDIFF(DateLastHere,Bookedindate) 
FROM `cases` 
WHERE serialnumber like 'TTTT46'

1 个答案:

答案 0 :(得分:3)

你可以这样做

$data   =   array(
            'case_id',
            'serialnumber',
            'DateLastHere',
            'Bookedindate',
            'DATEDIFF(DateLastHere,Bookedindate)'
            );
$this->db->select($data);
$this->db->from('cases');
$this->db->like('serialnumber','TTTT46');
$query = $this->db->get()->result_array();