Monday, 15 April 2013

php - Codeigniter causing mysql syntax error -


I would like to know whether r.is_show_map = 1, if true, return r.lat, otherwise, return tap

Here is the code

  $ this-> Db- & gt; Select ('r.lat', false) as' R. *, If (r.is_show_map = 1, r.lat, null);  

The problem is that syntax error

  error number: 1064 You have an error in your SQL syntax; To use the closest '.lat FROM (in the form of `request'), check the manual related to your MySQL server version for the correct syntax WHERE` r`. `Adv_type`! = 0 and `r` .`__islete` = 0 AN 'Selection R on line 1. *, If (RIS_show_map = 1, RLT, faucet) RLT As (`request` as R) where` r`. ADV_type '! = 0 and `r` .`is_delete` = 0 and now () & lt; = DATE_ADD (r.create_date, INTERVAL 15 DAY)  

How to fix it? Thanks

Try this:

  $ this-> Db- & gt; Select 'Latitude' as 'R. *, IF (RIS_show_map = 1, RLT, blank)', Incorrect);  

No comments:

Post a Comment