我有一个codeigniter
应用程序,我需要year
从mysql字段获取datetime
数据类型。我需要使用CIactive record
通过以下方式进行此操作。
$this->db->select(YEAR("added_date"));
$this->db->from("news");
$this->db->order_by("added_date", "DESC");
$this->db->where('published', 1);
$this->db->distinct();
$this->db->get();
但出现以下错误:
Call to undefined function YEAR() in /opt/lampp/htdocs/...
我使用codeigniter 2.1.x(如果需要)
YEAR
是MYSQL函数而不是codeigniter函数:
$this->db->select('YEAR(`added_date`)');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句