CodeIgniter:如何在模型codeigniter中编写timestampdiff查询?

时间:2016-09-28 08:11:52

标签: php mysql codeigniter

在phpmyadmin我可以运行此查询

Select * from tbl_member where id_group= 'value' and TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN '0' and  '19'

但在我的模型中,我无法运行此查询

class Member_m extends CI_Model {

    function select_member($id_group,$age_min,$age_max){
        $condition = " TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN '".$age_min."' and '".$age_max."' ";
        $this->db->select('*');
        $this->db->from('tbl_member');
        $this->db->where('id_group',$id_group);
        $this->db->where($condition);
        $query = $this->db->get();

        return $query;
    }
}

我试图把最小年龄的成员带到最大年龄,例如,我想把成员的成员从10岁到19岁......任何人都可以帮助我吗?

0 个答案:

没有答案