如何使用与活动记录类似的方式编写选择查询?
SELECT * FROM test_tbl WHERE date BETWEEN '$start' and '$end' ORDER BY ID
此致
答案 0 :(得分:7)
AFAIK,没有对BETWEEN
你可以这样做
$this->db->where("date BETWEEN '$start' AND '$end'");
$this->db->get("test_tbl");
或者编写一个看起来像这样的辅助函数
function where_between($field, $min, $max){
$CI = get_instance();
return $CI->db->where("`$field` BETWEEN '$min' AND '$max'");
}
稍后,您可以通过调用where_between('test_tbl', $start, $end)