CodeIgniter Forums

Full Version: this->db->select contain function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Code:
$this->db->select("*, DATE_FORMAT(news_time,'%d/%m/%Y') AS vn_date,DATE_FORMAT(news_time,'%Hh%i\'%s\"') AS vn_clock,CASE WHEN DATE_FORMAT(news_time,'%Hh%i\'')>type_time THEN false ELSE true END AS is_ontime",false)
I want to break news_time column into date part and clock part so I use 2 DATE_FORMAT function but it causes an error:
Code:
SELECT *, DATE_FORMAT(news_time, '%d/%m/%Y') AS vn_date, '%Hh%i\'%s"') AS vn_clock, CASE WHEN DATE_FORMAT(news_time, '%Hh%i\'')>type_time THEN false ELSE true END AS is_ontime
We can see that 2 functions DATE_FORMAT is not recognized corectly, to avoid this I have to use an trick:
Code:
$this->db->select("*, DATE_FORMAT(news_time,'%d/%m/%Y') AS vn_date,CASE WHEN true THEN DATE_FORMAT(news_time,'%Hh%i\'%s\"') END AS vn_clock,CASE WHEN DATE_FORMAT(news_time,'%Hh%i\'')>type_time THEN false ELSE true END AS is_ontime",false)