• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
this->db->select contain function

#1
[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)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.