我有一个旅行表,它存储旅行的详细信息。其中一个字段存储日期和类型是DATETIME。我正在按日期创建搜索查询。在codeigniter中搜索
$q can be
$q = 2012 when searching for years
$q = 1-12 when searching for months
$q = 1-31 when searching for days
但搜索时,说了个月在多部未华,有许多行他们中的一些是2002-02-13 04:44:48, 2013-02-13 04:44:48, 2013-02-13 02:44:48
等,他们都将显示,因为它们都含有他们。但我的意图是在本月获得该行。我该怎么做,以什么为适当的方式。
function search($q){
$this->db->select('*');
$this->db->from('trips');
$this->db->like('date',$q);
// Execute the query.
$query = $this->db->get();
// Return the results.
return $query->result_array();
}
我可以储存日,月,年等不同领域完成它,但是反正是有做,在我已经指出了道路。