![]() |
codeigniter active record bug? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: codeigniter active record bug? (/showthread.php?tid=26424) |
codeigniter active record bug? - El Forum - 01-13-2010 [eluser]Unknown[/eluser] Hi all I want to know if this is a bug , or just my mistake when i want to select two column of datetime type this works Code: $this->db->select("promotion_id as pkey, code, name, DATE_FORMAT(start_date, '%d %b, %Y'), DATE_FORMAT(end_date,'%d %b %Y'), total_qty, rent_day", false); but this doesn't works Code: $this->db->select("promotion_id as pkey, code, name, DATE_FORMAT(start_date, '%d %b, %Y'), DATE_FORMAT(end_date,'%d %b, %Y'), total_qty, rent_day", false); is this a bug or what? codeigniter active record bug? - El Forum - 01-13-2010 [eluser]JHackamack[/eluser] Right after your query runs have you echoed out: $this->db->last_query(); are the results the same, or different for the second date format. Also another thing to try that might be foiling it is aliasing your columsn DATE_FORMAT(start_date, '%d %b, %Y') as start_date I believe MySQL assigns a date_format to both columns, so one will overwrite the other. codeigniter active record bug? - El Forum - 01-13-2010 [eluser]Unknown[/eluser] [quote author="JHackamack" date="1263423314"]Right after your query runs have you echoed out: $this->db->last_query(); are the results the same, or different for the second date format. Also another thing to try that might be foiling it is aliasing your columsn DATE_FORMAT(start_date, '%d %b, %Y') as start_date I believe MySQL assigns a date_format to both columns, so one will overwrite the other.[/quote] If you notice carefully the code sample that I gave you, you will find the difference is only a matter of a comma DATE_FORMAT(end_date, '%d %b %Y') and DATE_FORMAT(end_date, '%d %b, %Y') --> this doesn't work yes I echoed the query (the one without a comma) and tried it on phpmyadmin to see if it is correct the query runs OK, I got what I wanted and when I added a comma to the date format of the second date column it also runs OK it gives me two column of date with '%d %b, %Y' but when I give this format to active records it failed It only accept one '%d %b, %Y' (with comma) and one '%d %b %Y' (without comma) my summary is active records only accepts DATE_FORMAT(end_date, '%d %b %Y') and DATE_FORMAT(end_date, '%d %b, %Y') in one query it cannot accepts DATE_FORMAT(end_date, '%d %b, %Y') and DATE_FORMAT(end_date, '%d %b, %Y') can someone try this ? I think this is very not right to have codeigniter active record bug? - El Forum - 01-13-2010 [eluser]JHackamack[/eluser] Deleted codeigniter active record bug? - El Forum - 01-14-2010 [eluser]danmontgomery[/eluser] Tried this locally and both queries work fine for me, I think your problem is something else. Code: $this->load->database(); Quote:stdClass Object codeigniter active record bug? - El Forum - 01-14-2010 [eluser]JHackamack[/eluser] [quote author="noctrum" date="1263506176"]Tried this locally and both queries work fine for me, I think your problem is something else. Code: $this->load->database(); Quote:stdClass Object[/quote] The problem that i see is all your dates are formatted the same way in the result, even though you specified a different format in date_format. AKA: %d %b %Y returns 14 Jan, 2010 in your result (where did the comma come in) codeigniter active record bug? - El Forum - 01-14-2010 [eluser]danmontgomery[/eluser] I realized after I posted that I pasted the results without the comma rather than the results with the comma, so I tried to fix my post... Not an actual problem. |