ActiveRecord - What's wrong with this statement? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: ActiveRecord - What's wrong with this statement? (/showthread.php?tid=35247) Pages:
1
2
|
ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]stormbytes[/eluser] I used something similar in another query. The only difference are the single-quotes & the slash. Tried in in SQLpro and it works fine. CI returns the second field of the query (`revisions`) just fine, but chokes on the date field. What's wrong with this? Code: $rows = $this->db->select("DATE_FORMAT(`date`, '%c-%d-%y / %1:%i %p') AS Date, `revision`", FALSE) ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]InsiteFX[/eluser] MySQL DATE_FORMAT InsieFX ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]tonanbarbarian[/eluser] $this->db->select only builds the select statement, it does not execute the query. [code]$this->db->select("DATE_FORMAT(`date`, ' ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]stormbytes[/eluser] I realize that - it's followed by the get() statement. I'm gonna try MySQL DATE_FORMAT as was suggested by InstallFX ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]stormbytes[/eluser] Tried it - No go Code: $rows = $this->db->select("MySQL DATE_FORMAT(`date`," .$date_format." ) AS Date, `revision`", FALSE); ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]tonanbarbarian[/eluser] tell us the exact query you expect it to produce and then run the following command after the ->db->get() and see what the query is actually producing Code: echo $this->db->last_query(); ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]stormbytes[/eluser] [quote author="tonanbarbarian" date="1287901783"]tell us the exact query you expect it to produce and then run the following command after the ->db->get() and see what the query is actually producing Code: echo $this->db->last_query(); I expect it to access the 'Revisions' table, retrieve the 'date' field, format the date field like I expressed, retrieve the revisions field, and return the data to the controller that called it. Frankly I'm really stumped. This query works just fine in mysql client locally - In fact, it actually half-works in CI. It retrieves the data from the revision field but the date field is generating an error. I'm guessing it's got something to do with the single-quotes as I've executed similar functions in other queries without a problem. ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]stormbytes[/eluser] Here's the result from the echo->db->last_query() operation: Code: SELECT DATE_FORMAT(`date`, '%c-%d-%y / %1:%i %p' ) AS Date, `revision` FROM (Revisions) Now I'm even more stumped! It looks PERFECT! Why is it generating THIS error!? Code: A PHP Error was encountered Here is revisions.php Code: <!DOCTYPE html> ActiveRecord - What's wrong with this statement? - El Forum - 10-23-2010 [eluser]stormbytes[/eluser] Oh my !&#^*$^#@*&$ GOD!???? Somebody shoot me! The stupid thing's CASE SENSITIVE!?!? The php parser/CI didn't like that I was calling the result->field with a small 'd' Lol 3 hours over this?!?!?!? ActiveRecord - What's wrong with this statement? - El Forum - 10-24-2010 [eluser]WanWizard[/eluser] Variables in PHP are case sensitive. One of the main reasons why the PHP style guide in the manual states you should stick to lowercase and use underscores, and not use CamelCase, for variable names. |