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

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -