php - How to write TIMESTEMPDIFF QUERY in model codeigniter? -
in mysql phpmyadmin can run query :
select timestampdiff (month, periodmulai, periodselesai) tb_projek but how write query in model codeignitor way? doesn't work
public function get_bulan() { $this->db->select_timestampdiff('month,tb_projek.periodmulai,tb_projek.periodselesai'); $this->db->from('tb_projek'); $query = $this->db->get(); return $query->result(); }
use this,
$this->db->select('timestampdiff(month,periodmulai,periodselesai )',false); $this->db->from('tb_projek'); if set false, codeigniter not try protect field or table names backticks. useful if need compound select statement.
Comments
Post a Comment