我想从db加载我的客户的约会历史记录,每条记录都有start_datetime
和end_datetime
,实际上我的查询如下:
$query = $this->db
->select('*')
->from('appointments')
->where('id', 5) 'id of record to select
->where('start_datetime' ) 'here's indecision
->get()->result_array();
基本上要加载的记录应该是当前日期时间的所有记录。我如何在where子句中传递这个条件?
答案 0 :(得分:2)
试试这个
$now = date('Y-m-d H:i:s'); # get current time stamp
$query = $this->db
->select('*')
->from('appointments')
->where('id', 5)
->where(start_datetime <= $now ) # Sometimes date($now)
->get()->result_array();