How to write this query with codeigniter?
How to write select query with between similar to this with active record?
SELECT * FROM test_tbl WHERE date BETWEEN '$start' and '$end' ORDER BY ID
Re开发者_运维技巧gards
AFAIK, there's no built-in support for BETWEEN
You can do this instead
$this->db->where("date BETWEEN '$start' AND '$end'");
$this->db->get("test_tbl");
Or write a helper function that look like this
function where_between($field, $min, $max){
$CI = get_instance();
return $CI->db->where("`$field` BETWEEN '$min' AND '$max'");
}
Later on, you can use that function by calling it like where_between('test_tbl', $start, $end)
精彩评论