[SOLVED] Query with filters - 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: [SOLVED] Query with filters (/showthread.php?tid=41990) |
[SOLVED] Query with filters - El Forum - 05-23-2011 [eluser]predat0r[/eluser] Hey, I have a DATE (example: 2011-05-23) in my table and want to filter by year and month, with this date structure. I know (guess) I can use mysql MONTH() or DATE_FORMAT() functions but how to implement them? I tried to put MONTH in the like or where statements but gets error, and DATE_FORMAT in the select, with no success.. My code snippet: $query_array contains the filter options from dropdowns, for example evek = 2010, and honapok = 05 To be honest, filtering by year works, because there are only one 2010, but for month, 05 could be a month or a day, or a part of a year also.. Code: function get_all_galleries($query_array, $limit, $offset) { thank you [SOLVED] Query with filters - El Forum - 05-23-2011 [eluser]danmontgomery[/eluser] Code: $this->db->where('MONTH(`datum`)', $query_array['evek'], FALSE); [SOLVED] Query with filters - El Forum - 05-23-2011 [eluser]predat0r[/eluser] [quote author="noctrum" date="1306165131"] Code: $this->db->where('MONTH(`datum`)', $query_array['evek'], FALSE); Oh yeah, the pros know all thanks |